paths-filter icon indicating copy to clipboard operation
paths-filter copied to clipboard

Pass matrix object array as filter

Open mbjelac opened this issue 2 years ago • 1 comments

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.

mbjelac avatar Dec 07 '22 11:12 mbjelac

Check https://github.com/hellofresh/action-changed-files

awoimbee avatar May 26 '23 15:05 awoimbee