paths-filter
paths-filter copied to clipboard
Pass matrix object array as filter
Apologies if some doc or issue already explains this, I have browsed through several and haven't found this case:
Is it possible to have a single job run as a matrix (so, actually multiple jobs) so that one of the job's steps is the paths-filter action but its filter is dynamically set from an array in the matrix object property, like:
my-job:
runs-on: ubuntu-latest
strategy:
matrix:
case:
- {
diffFilters: [
'src/**/folder1/**',
'src/**/folder2/**'
],
fileToRun: FileA
}
- {
diffFilters: [
'src/**/folder3/**',
'src/**/folder4/**'
],
fileToRun: FileB
}
- {
diffFilters: [
'src/**/folder5/**',
'src/**/folder6/**'
],
fileToRun: FileC
}
steps:
- uses: actions/checkout@v2
- name: check code changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src: ${{ matrix.case.diffFilters }}
- name: run file
if: steps.changes.outputs.src == 'true'
run: |
# run the file from ${{ matrix.case.fileToRun }}
it seems more readable to me that the changes are checked in the same job they are evaluated in.
the above workflow always ends up with false
, so the run file
step is never executed.
Check https://github.com/hellofresh/action-changed-files