← ClaudeAtlas

gha-pr-merge-ref-shows-upstream-changeslisted

Diagnose "my CI failed on a file I didn't change — the test passes locally but CI insists there's a duplicate / conflict / lint violation that isn't in my branch." Caused by GitHub Actions checking out `refs/pull/N/merge` (the auto-computed merge of PR head + base) on `pull_request` events. Use when: (1) CI fails on a `git`/lint/whole-tree check (duplicate IDs, schema drift, file-content audit) that PASSES on the same SHA locally, (2) you're working in a dense parallel-PR window where main is moving faster than your CI runs, (3) `gh run view N --json headSha` matches your latest force-push but `git fetch origin main && git diff origin/main..HEAD` shows main is ahead by N commits, (4) the failure references symbols / IDs / values that are present in MAIN but absent from your branch. Root cause: GitHub re-computes the merge ref every time the base moves, so CI on `pull_request` sees `main-at-CI-start + your-branch`, NOT just `your-branch`. Sister concept to `gha-billing-failure-fast-fail-pattern` (different GHA
wan-huiyan/agent-traffic-control · ★ 2 · Code & Development · score 79
Install: claude install-skill wan-huiyan/agent-traffic-control
# GHA `pull_request` Event Uses Merge-Ref, Not Head-Ref ## Problem You push a commit to a PR branch at T0. CI starts running at T0+10s. A sibling PR merges to main at T0+5s. Your CI run **sees the sibling's changes mixed into your branch** and fails on something neither side introduced alone. Most confusingly: locally on the exact same commit SHA, every check passes. `gh run view <N> --json headSha` reports your SHA correctly. `git show <SHA>:<file>` shows your file is clean. But CI failed on that SHA citing duplicates / conflicts / violations that aren't there. ## Context / Trigger Conditions - CI failure on a `pull_request` event (NOT `push`) - Failure cites a violation in a file you didn't touch in your last push - The same SHA passes the same check locally - `gh run view <N> --json headSha` matches your local HEAD - `git fetch origin main && git rev-list --left-right --count origin/main...HEAD` shows main is ahead by 1+ commits since your push - The failure message references identifiers / strings present in main but not in your branch (e.g. "duplicate ID `X`" where `X` was added to main by a PR that merged seconds before your CI ran) - You're in a dense parallel-PR window (multiple PRs merging within minutes — release day, mass-merge sweep, several agents shipping concurrently) ## Root cause GitHub Actions, when triggered by `pull_request: [opened, synchronize, reopened, ...]`, checks out a SYNTHETIC ref called `refs/pull/<N>/merge`. This ref is the **3-