Skip to content
Latchkey

How to Run a Job After Another Workflow Completes in GitHub Actions

Some jobs should only fire after a separate workflow finishes; workflow_run chains them without merging the files.

Use the workflow_run trigger naming the upstream workflow, then gate the job on github.event.workflow_run.conclusion.

Steps

  • Add a workflow_run trigger referencing the upstream workflow by name.
  • Filter on the branches and event types you care about.
  • Gate the job with if: github.event.workflow_run.conclusion == 'success'.
  • Read upstream metadata from the github.event.workflow_run context.

Workflow

.github/workflows/after-ci.yml
on:
  workflow_run:
    workflows: ['CI']
    types: [completed]
jobs:
  deploy:
    if: github.event.workflow_run.conclusion == 'success'
    runs-on: ubuntu-latest
    steps:
      - run: echo "CI ${{ github.event.workflow_run.head_sha }} passed; deploying"

Gotchas

  • The triggered workflow runs from the default branch, not the head branch of the upstream run.
  • Without the conclusion gate, the job also runs after failed and cancelled upstream runs.
  • Latchkey runs these chained workflows on cheaper runners and retries the follow-up on transient launch failures.

Related guides

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