Reputation: 385
For example in my repository I have 3 github action workflows: linting(L), unittests(U) and also build(B) workflow which I want to trigger only when L and U are done. Both L and U trigger automatically on a push event. If I do this in B workflow:
workflow_run:
workflows: ["Lint", "UnitTests"]
types:
- completed
I get my build workflow triggered twice, first time when L finishes and second time when U finishes. Is it possible to trigger B only once when both L and U have finished?
Upvotes: 6
Views: 2842
Reputation: 40849
This is not possible out of the box. It works like OR
here. If you want to trigger this workflows only when both workflow finished you need to introduce some kind of orchestrator here which will store state and keep information about already executed workflows. It could be some stateful app. However, this is huge effort.
Upvotes: 4
Reputation: 1891
For now, there is no nice way of avoiding this, but if the triggering jobs take the same time, you can use the concurrency
feature of GitHub Workflows:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
This will avoid running both jobs concurrently and cancel the first one to run, but it depends on the time it takes to complete the trigger workflows. If the run time difference between the triggering workflows is longer than the triggered workflow run time, then it will run twice completely anyway.
Upvotes: 0