In a github workflow (.yaml) script, I'm wondering how to loop through any folders that have changes as part of a particular PR.
For instance, suppose I have this structure:
Dir1\File1.txt
Dir2\File2.txt
Dir3\File3.txt
Dir4\File4.txt
If a PR has changes to File2.txt and File4.txt, I want a workflow that will loop thru and do something in folders: Dir2 and Dir4.
I know of a way to do this for specific folders, but I don't want to have to specify all of the folders that exist in my source, i.e. this works for a list of specified directories:
- name: myJob
run: |
myDirectories=("Dir1" "Dir2" "Dir3" "Dir4")
for i in "${myDirectories[@]}"
do
if git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -c "^$i/"; then
...do something...
fi
done
Thank you.