Description
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 |