Interview Prep/GitHub Actions/Pipeline Design & Triggers

Two workflows must run in sequence: CI then a separate deploy workflow owned by another team. How do you link them?

IntermediateScenarioPipeline Design & Triggers
Answer

Situation read → Separate files, possibly separate owners.

What I'd do →

  1. Prefer making deploy a reusable workflow the CI calls as a job with needs. One run, one graph, outputs passed directly.
  2. If they must stay separate, use workflow_run:
    on:
      workflow_run:
        workflows: ["CI"]
        types: [completed]
        branches: [main]
    jobs:
      deploy:
        if: github.event.workflow_run.conclusion == 'success'
    
  3. Use github.event.workflow_run.head_sha to deploy exactly the CI-tested commit, and download its artifact with run-id.

Why → workflow_run alone triggers on failures too and runs on the default branch context, so the conclusion and SHA checks are required.

Interview tip → Mention that workflow_run only chains up to three levels deep.

All GitHub Actions questions Roadmap: GitHub Actions

More on Pipeline Design & Triggers