'Github actions workflow 'on' and conditions
on:
push:
branches:
- '**'
paths:
- 'dataloaders/xxx/**'
workflow_run:
workflows: ['CI']
types:
- completed
jobs:
xxx_test:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
I want to achieve something like this: so above workflow only get run when both the two conditions: path 'dataloaders/xxx/**' got changes and CI workflow successfully completed are met, now seems it is or(||) between this two conditions, thus: the path filter is ignored!
How can i make the conditions be and(&&)?
Solution 1:[1]
You can't achieve what you want using those on trigger alone.
This happens because those triggers work separately (according to one OR the other condition).
In that case, the workaround is the use only one condition at the on trigger level, then check the other condition inside the workflow / jobs steps, using an if condition.
For example, at the place you use the condition if: ${{ github.event.workflow_run.conclusion == 'success' }}, you could add another check using if: [...] && [variable telling me if the path I want has been updated]
However, in your particular scenario, checking a path has been updated after another workflow run conclusion isn't easy.
My suggestion would be, instead of triggering your new workflow like this, to trigger this workflow by a workflow_dispatch or a repository_dispatch event, calling this workflow in a separate job at the end of the previous workflow (the one called CI), where this job would only be executed if all other jobs from the CI workflow would be executed successfully, and if the path you want has been updated (for example, using a path-filter action to check the path and decide if you should call or not your new workflow).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | GuiFalourd |
