Booleans for any / all changes detected
Greetings!
I am wondering if it's possible to add output booleans called any and all to match the conditions where any or all of the filters are evaluated as true?
Using the example from the README.md file:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
# run only if 'backend' files were changed
- name: backend tests
if: steps.filter.outputs.backend == 'true'
run: ...
# run only if 'frontend' files were changed
- name: frontend tests
if: steps.filter.outputs.frontend == 'true'
run: ...
# run if 'backend' or 'frontend' files were changed
- name: e2e tests
if: steps.filter.outputs.backend == 'true' || steps.filter.outputs.frontend == 'true'
run: ...
In that example, the e2e tests step needs to know about the keys backend and frontend. This works for a normal workflow, but I am putting the dorny/paths-filter@v3 inside of a reusable workflow, and I want to give the user the option to pass in additional filters.
In that scenario, my e2e tests (which is inside of a reusable workflow) wouldn't know which keys are important. I would instead want something like this:
# run if 'backend' or 'frontend' files were changed
- name: e2e tests
if: steps.filter.outputs.any == 'true'
run: ...
Using steps.filter.outputs.any == 'true' would replace the OR check of steps.filter.outputs.backend == 'true' || steps.filter.outputs.frontend == 'true'.
Is this possible?
Going further, the matrix of the above would evaluate as follows:
| Backend | Frontend | Any | All |
|---|---|---|---|
| true | true | true | true |
| true | false | true | false |
| false | true | true | false |
| false | false | false | false |
alternative for any:
${{ steps.filter.outputs.changes != '[]' }}
alternative for all:
${{ ! contains(toJSON(steps.filter.outputs), '"false"') }} # could fail if an output is named false (which gets listed in output "changed")
my used references: https://github.com/dorny/paths-filter?tab=readme-ov-file#outputs https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#contains
@SimonHeimberg does that mean you'd prefer not to merge this ?
What I suggest is more a way to do it with the current code than an opinion. I will not use those outputs because I have no user provided input to pass on. But I do not care about additional outputs. I am not responsible for the code and did not even contribute.