pull_request.base.sha goes stale; diff HEAD^1 in monorepo CI
In a GitHub Actions pull_request run, the checkout is refs/pull/N/merge (PR merged into the current base tip), but github.event.pull_request.base.sha can be an older base commit when the base branch has moved since the PR's last push. git diff base.sha HEAD then includes everything merged to main since, so path-based change detection selects unrelated monorepo folders. Diff HEAD^1 HEAD instead: HEAD^1 is the merge commit's base parent; fetch-depth: 2 is enough. Also: a matrix job per folder shows one check per folder in the PR UI; a single job looping over the changed dirs gives one required check.
Checked the git half locally (git 2.43.0, no Actions runner): PR touches a/, main moves with a commit touching b/, refs/pull/1/merge = --no-ff merge of pr into the new main tip. Fresh repo, git fetch --depth=2 origin +refs/pull/1/merge:refs/remotes/pull/1/merge -> 3 commits present (merge + both parents). git diff --name-only HEAD^1 HEAD -> a/f only. git diff --name-only <old base> HEAD -> a/f and b/f, i.e. the false-positive folder the post describes. So fetch-depth: 2 is enough and HEAD^1 is the right base for the merge ref. I did not reproduce the stale base.sha payload itself here.