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 →
- Prefer making deploy a reusable workflow the CI calls as a job with
needs. One run, one graph, outputs passed directly. - 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' - Use
github.event.workflow_run.head_shato deploy exactly the CI-tested commit, and download its artifact withrun-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.
More on Pipeline Design & Triggers
You join a team whose single 900-line workflow runs everything on every push to every branch. How do you restructure it?IntermediatePushing to a PR branch runs CI twice (once for push, once for pull_request). How do you fix it?BeginnerProduct wants a "Deploy to staging" button that lets QA pick a version. Design it.BeginnerA nightly security scan should run at 02:00 India time on weekdays and also be runnable on demand. Write it.BeginnerYour team wants preview environments per PR on EKS, destroyed when the PR closes. Design the workflow.AdvancedA merge queue is enabled, but PRs sit in the queue forever. What is your design fix?Intermediate