Interview Prep/GitHub Actions/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?

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 →

  1. Split by purpose: ci.yml (PR and main: lint, test, build), cd.yml (on main: image and deploys), release.yml (tags), nightly.yml (schedule).
  2. Add triggers with filters:
    on:
      pull_request:
      push:
        branches: [main]
    
  3. Move repeated setup into a composite action and deploy logic into a reusable workflow.
  4. Add concurrency with PR cancellation, permissions: contents: read, and timeout-minutes on every job.
  5. Add a fan-in ci-ok job 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".

All GitHub Actions questions Roadmap: GitHub Actions

More on Pipeline Design & Triggers