Interview Prep/GitHub Actions/Pipeline Design & Triggers

Pushing to a PR branch runs CI twice (once for push, once for pull_request). How do you fix it?

BeginnerScenarioPipeline Design & Triggers
Answer

Situation read → on: [push, pull_request] with no branch filters fires both events for every commit on a PR branch.

What I'd do →

  1. Restrict push to long-lived branches and let PRs cover feature branches:
    on:
      push:
        branches: [main, "release/**"]
      pull_request:
    
  2. Add concurrency keyed on PR number or ref so leftovers cancel.

Why → Halves CI minutes for feature work while still validating main after merge.

Interview tip → Mention that pull_request tests the merge commit, which is more valuable than testing the branch head alone.

All GitHub Actions questions Roadmap: GitHub Actions

More on Pipeline Design & Triggers