Interview Prep/CI/CD/GitHub Actions

A deployment workflow should run only after CI succeeds on main.

IntermediateScenarioGitHub Actions
Answer

Situation read → Chain workflows.

What I'd do →

  1. Option A: one workflow with jobs.deploy.needs: [test] and if: github.ref == 'refs/heads/main'.
  2. Option B: on: workflow_run: workflows: [ci], types: [completed], branches: [main] with if: github.event.workflow_run.conclusion == 'success'.

Why → One workflow is simpler and shows one graph; workflow_run is useful when workflows live separately, but runs with different context and must check out the correct SHA.

Interview tip → With workflow_run, check out github.event.workflow_run.head_sha.

All CI/CD questions

More on GitHub Actions