Commit 8dc2bf0
fix(ci): checkout the event SHA in governance jobs (re-enable PR-time enforcement) (#442)
## Summary
Fixes the estate-wide governance failure where **8 of 10 jobs in
`governance-reusable.yml` die at checkout on every PR** with:
```
fatal: couldn't find remote ref refs/pull/<n>/merge
```
(This is the `refs/pull/<n>/merge` item flagged as out-of-scope in #441
— now resolved with owner approval.)
## Root cause
`governance.yml` triggers on `pull_request` and calls
`governance-reusable.yml` via `workflow_call`. Inside a **reusable**
workflow, `github.ref` inherits the caller's PR ref, which on a
`pull_request` event is the *named merge ref* `refs/pull/<n>/merge`. The
8 jobs that pass `ref: ${{ github.ref }}` to `actions/checkout`
therefore ask it to `git fetch refs/pull/<n>/merge` — a named ref
checkout cannot resolve — and fail at the checkout step.
The two jobs that **omit** an explicit `ref:` (`workflow-staleness`,
`validate-hypatia-baseline`) use checkout's default and were unaffected
— exactly matching the observed **8/10**.
**Consequence today:** governance is effectively **ungated on PRs** —
only `push`-to-`main` runs enforce.
## Fix
Pin the 8 caller-repo checkouts to **`ref: ${{ github.sha }}`** — the
concrete event commit (the PR merge commit on `pull_request`, the pushed
commit on `push`). It resolves to the *same* commit
`refs/pull/<n>/merge` points at, but is always fetchable. A short
comment at each site explains why `github.ref` must not be used here.
- Affected jobs: `language-policy`, `package-policy`, `security-policy`,
`quality`, `wellknown`, `workflow-lint`, `trusted-base`,
`licence-consistency`.
- The 3 secondary `repository: hyperpolymath/standards` + `ref: main`
checkouts (which fetch the check scripts) are **untouched**.
- Content/enforcement semantics are preserved: the diff-based step
(`quality`'s trufflehog) already uses explicit `github.sha` /
`github.event.pull_request.base.sha`, independent of the checkout ref.
## Blast radius (owner-acknowledged)
This **re-enables PR-time governance enforcement across every repo**
consuming the reusable workflow. PRs that were silently passing (because
the jobs never ran) may now surface real governance violations. Approved
by owner 2026-06-27.
## Verification
- `python3 -c "import yaml; yaml.safe_load(...)"` → **YAML OK**.
- Structural check: 13 checkout steps total — 2 bare (unchanged), 8 now
`ref: ${{ github.sha }}`, 3 standards-checkout `ref: main` (unchanged).
No `ref: ${{ github.ref }}` remains.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01MJdfXv5E5gwGD2yaJq8jRM)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent e9c8888 commit 8dc2bf0
1 file changed
Lines changed: 72 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
| |||
464 | 472 | | |
465 | 473 | | |
466 | 474 | | |
467 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
468 | 484 | | |
469 | 485 | | |
470 | 486 | | |
| |||
492 | 508 | | |
493 | 509 | | |
494 | 510 | | |
495 | | - | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
496 | 520 | | |
497 | 521 | | |
498 | 522 | | |
| |||
723 | 747 | | |
724 | 748 | | |
725 | 749 | | |
726 | | - | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
727 | 759 | | |
728 | 760 | | |
729 | 761 | | |
| |||
772 | 804 | | |
773 | 805 | | |
774 | 806 | | |
775 | | - | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
776 | 816 | | |
777 | 817 | | |
778 | 818 | | |
| |||
830 | 870 | | |
831 | 871 | | |
832 | 872 | | |
833 | | - | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
834 | 882 | | |
835 | 883 | | |
836 | 884 | | |
| |||
874 | 922 | | |
875 | 923 | | |
876 | 924 | | |
877 | | - | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
878 | 934 | | |
879 | 935 | | |
880 | 936 | | |
| |||
897 | 953 | | |
898 | 954 | | |
899 | 955 | | |
900 | | - | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
901 | 965 | | |
902 | 966 | | |
903 | 967 | | |
| |||
0 commit comments