Skip to content
Latchkey

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 and types: [completed].
  • Gate on the upstream conclusion to 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

Run this faster and cheaper on Latchkey managed runners. Start free →