How to Combine a Merge Queue With Incremental CI
The merge queue builds a candidate merge commit and fires the merge_group event; running your affected detection against that group base keeps incremental CI correct as PRs combine.
A merge queue tests the actual combination of queued PRs before merge. Add the merge_group trigger and compute your affected set against the group base so incremental selection reflects the batched change, not a single PR.
Steps
- Add
merge_groupto the workflow triggers. - Use the merge group base ref for change detection.
- Keep the same required checks so the queue enforces them.
Workflow
.github/workflows/ci.yml
on:
pull_request:
merge_group:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: npm ci
# affected against the base the queue is merging into
- run: npx nx affected -t test --base=origin/mainGotchas
- Incremental selection at PR time can miss a break that only appears when two PRs combine; the merge queue re-testing the group is what catches it.
- Required checks must be configured to run on
merge_group, or the queue cannot verify them.
Related guides
How to Skip Duplicate CI RunsStop redundant GitHub Actions runs with a concurrency group that cancels superseded runs, and skip duplicate…
How to Fix Stuck Required Checks With Conditional JobsSolve the pending required check problem in incremental CI, where a skipped job never reports status, by usin…
How to Skip Work Safely With Dependency-Aware SelectionKeep incremental CI correct by including dependents when you skip, so a change to a shared module still re-te…