I'm using dorny/paths-filter
to detect changes. The problem is I want to run a success job for each of the unchanged filters. This way I can enforce waiting for all jobs in GitHub's rules.
My workflow looks like this:
jobs: # JOB to run change detection changes: runs-on: ubuntu-latest # Required permissions permissions: pull-requests: read outputs: # Expose matched filters as job 'packages' output variable changed-packages: ${{ steps.filter.outputs.changes }} UNCHANGED-packages: ${{ steps.filter.with.doesnt.exist.😡 }} steps: - uses: dorny/paths-filter@v3 id: filter with: filters: | package1: src/package1 package2: src/package2 # JOB to build and test each of modified packages build: needs: changes strategy: matrix: # Parse JSON array containing names of all filters matching any of changed files # e.g. ['package1', 'package2'] if both package folders contains changes package: ${{ fromJSON(needs.changes.outputs.changed-packages) }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - ... # JOB to approve folders that have NOT changed approve: needs: changes strategy: matrix: # Parse JSON array containing names of all filters matching any of UNCHANGED files package: ${{ fromJSON(needs.changes.outputs.UNCHANGED-packages) }} runs-on: ubuntu-latest steps: - run: success()🤷🏻♂️🤷🏻♂️
I was thinking maybe I can use some combination of setOutput
, toJson()
, getInput()
, maybe jq
?
Can I somehow get the object keys for the "with" property? Unfortunately, when I log the toJson(steps)
I get:
{"filter": {"outputs": {"package1": "false","package1_count": "0","package2": "true","package2_count": "3","changes": "[\"package2\"]" },"outcome": "success","conclusion": "success" } }
So I don't know what to do. Is there a better library than dorny/paths-filter
to accomplish?