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.
So, My workflow looks like this:
<code>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 }}
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.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(????????♂️????????♂️????????♂️????????♂️????????♂️) }}
runs-on: ubuntu-latest
steps:
- run: success()????????♂️????????♂️
</code>
<code>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 }}
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.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(????????♂️????????♂️????????♂️????????♂️????????♂️) }}
runs-on: ubuntu-latest
steps:
- run: success()????????♂️????????♂️
</code>
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 }}
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.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(????????♂️????????♂️????????♂️????????♂️????????♂️) }}
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:
<code> {
"changes": {
"outputs": {
"package1": "false",
"package1_count": "0",
"package2": "true",
"package2_count": "3",
"changes": "["package2"]"
},
"outcome": "success",
"conclusion": "success"
}
}
</code>
<code> {
"changes": {
"outputs": {
"package1": "false",
"package1_count": "0",
"package2": "true",
"package2_count": "3",
"changes": "["package2"]"
},
"outcome": "success",
"conclusion": "success"
}
}
</code>
{
"changes": {
"outputs": {
"package1": "false",
"package1_count": "0",
"package2": "true",
"package2_count": "3",
"changes": "["package2"]"
},
"outcome": "success",
"conclusion": "success"
}
}
So, IDK what to do… very annoying. Is there a better library than dorny/paths-filter
to accomplish?