Execute command for changed flles in folder on push #1776
-
Hi !
What I'm trying to do : When there is a push on the repo, check the files. Run the command "staticrypt .... $file" if the file is in one of those folders. Could you help me with that ? Thanks ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
My work in progress would be :
|
Beta Was this translation helpful? Give feedback.
-
Hi @agenceKanvas, based on your provided GitHub Actions workflow, here are some modifications you can make to achieve your desired outcome:
Here's an updated version of your workflow: name: Staticrypt
on:
push:
branches:
- main
jobs:
changed_files:
runs-on: ubuntu-latest
name: Test changed-files
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
files: |
folder1/**
folder2/**
folder3/**
- name: Install Git
run: |
apt-get clean && apt-get update -y
apt-get install -y git
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install staticrypt
run: npm install -g staticrypt@3.*
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
staticrypt $file -p ${{ secrets.DECRYPTION_PASSPHRASE }} -d "$(dirname $file)" --short \
--template-title "Connexion" --template-instructions "Espace restreint, merci d'entrer le mot de passe." \
--template-button "Ouvrir la page" --template-color-primary "#113e9f" --template-color-secondary "#e4e4e4"
done
- name: Commit files
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "encrypted files"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
force: true Note
|
Beta Was this translation helpful? Give feedback.
Hi @agenceKanvas, based on your provided GitHub Actions workflow, here are some modifications you can make to achieve your desired outcome:
Here's an updated version of your workflow: