You join a team whose single 900-line workflow runs everything on every push to every branch. How do you restructure it?
IntermediateScenarioPipeline Design & Triggers
Answer
Situation read → One file, no filters, no separation of CI and CD: slow feedback, wasted minutes, and deploys mixed with tests.
What I'd do →
- Split by purpose:
ci.yml(PR andmain: lint, test, build),cd.yml(onmain: image and deploys),release.yml(tags),nightly.yml(schedule). - Add triggers with filters:
on: pull_request: push: branches: [main] - Move repeated setup into a composite action and deploy logic into a reusable workflow.
- Add
concurrencywith PR cancellation,permissions: contents: read, andtimeout-minuteson every job. - Add a fan-in
ci-okjob and make it the only required check.
Why → Smaller files are reviewable, PR feedback gets faster, and deploy permissions are isolated from test jobs.
Interview tip → Say "separate by trigger and by privilege", not just "split the file".
More on Pipeline Design & Triggers
Pushing 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.AdvancedTwo workflows must run in sequence: CI then a separate deploy workflow owned by another team. How do you link them?IntermediateA merge queue is enabled, but PRs sit in the queue forever. What is your design fix?Intermediate