I am working on a mono repository that contains multiple projects, each solution being in a different folder. What I'm trying to achieve is to run a scan action on a folder if changes were made to code in that folder. I thought of setting all the paths to each solution in the pull_request paths trigger and then based on the path that triggered the workflow run the scan on that folder.
I was thinking of doing something like this:
name: scan
on:
pull_request:
paths:
- 'path/to/folder/*'
- 'path/to/anotherfolder/*'
jobs:
output_path:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Determine triggering path
id: determine_path
run: |
# Get the list of paths being monitored
monitored_paths=$(echo "${{ github.event.pull_request.paths }}" | tr -d '[] ')
# Loop through each path
for path in $monitored_paths; do
# Check if the modified files include this path
if echo "${{ github.event.pull_request.changed_files }}" | grep -q "$path"; then
# Set the output variables and exit the loop
echo "::set-output name=triggering_path::$path"
break
fi
done
- name: Output path
run: |
echo "The following path triggered this job: ${{ steps.determine_path.outputs.triggering_path }}"```