How to Trigger a Workflow After Another Workflow in GitHub Actions
The workflow_run event fires when a named workflow completes, letting a second workflow react to the first result.
Add on.workflow_run naming the upstream workflows: and the types: (usually completed). Gate on github.event.workflow_run.conclusion == 'success' to act only on green runs.
Steps
- Add
workflow_run:naming the upstream workflow andtypes: [completed]. - Gate on the upstream
conclusionto act only on success. - Access upstream artifacts and metadata via
github.event.workflow_run.
Workflow
.github/workflows/publish.yml
on:
workflow_run:
workflows: ["CI"]
types: [completed]
jobs:
publish:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- run: echo "CI passed on ${{ github.event.workflow_run.head_branch }}"Gotchas
- The
workflows:value is the upstream workflow name, not its filename. - workflow_run runs from the default branch, so it can safely use secrets even when the upstream ran on a fork PR.
Related guides
How to Trigger a Workflow From an External System in GitHub ActionsKick off a GitHub Actions workflow from an outside system with the repository_dispatch event, sending a custo…
How to Trigger a Workflow on Deployment Status in GitHub ActionsRun a GitHub Actions workflow when a deployment status changes using the deployment_status event, so smoke te…