Skip to content

Commit b89ed12

Browse files
committed
fix(ci): checkout the event SHA, not refs/pull/<n>/merge, in governance jobs
The 8 governance-reusable.yml jobs that pass `ref: ${{ github.ref }}` to actions/checkout were failing at checkout on every PR with "couldn't find remote ref refs/pull/<n>/merge". Root cause: governance.yml triggers on pull_request and calls governance-reusable.yml via workflow_call. In a reusable workflow, github.ref inherits the caller's PR ref, which is the named merge ref refs/pull/<n>/merge. actions/checkout cannot fetch that named ref, so the 8 jobs that requested it died at checkout — leaving governance effectively ungated on PRs (only push-to-main runs were enforcing). The two jobs that omit an explicit ref (workflow-staleness, validate-hypatia-baseline) were unaffected, matching the observed 8/10 failure. Fix: pin those checkouts to `ref: ${{ github.sha }}` — the concrete event commit (the PR merge commit on pull_request, the pushed commit on push). github.sha resolves to the same merge commit refs/pull/<n>/merge points at, but is always fetchable. Content is unchanged; the diff-based jobs (quality trufflehog base/head) already use explicit SHAs, so enforcement semantics are preserved. The secondary `ref: main` checkouts that pull the standards check scripts are untouched. Estate-wide: re-enables PR-time governance enforcement across all repos that consume this reusable workflow. Owner-approved 2026-06-27. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MJdfXv5E5gwGD2yaJq8jRM
1 parent e9c8888 commit b89ed12

1 file changed

Lines changed: 72 additions & 8 deletions

File tree

.github/workflows/governance-reusable.yml

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,15 @@ jobs:
128128
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
129129
with:
130130
repository: ${{ github.repository }}
131-
ref: ${{ github.ref }}
131+
# Pin to the concrete event SHA (the PR merge commit on
132+
# pull_request, the pushed commit on push). Do NOT use
133+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
134+
# pull_request, github.ref is the named merge ref
135+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
136+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
137+
# governance jobs on every PR estate-wide. github.sha resolves to the
138+
# same merge commit but is always fetchable.
139+
ref: ${{ github.sha }}
132140

133141
# Estate language policy bans Python with no exceptions (CLAUDE.md
134142
# Language Policy; SaltStack exception removed 2026-01-03). The
@@ -464,7 +472,15 @@ jobs:
464472
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
465473
with:
466474
repository: ${{ github.repository }}
467-
ref: ${{ github.ref }}
475+
# Pin to the concrete event SHA (the PR merge commit on
476+
# pull_request, the pushed commit on push). Do NOT use
477+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
478+
# pull_request, github.ref is the named merge ref
479+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
480+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
481+
# governance jobs on every PR estate-wide. github.sha resolves to the
482+
# same merge commit but is always fetchable.
483+
ref: ${{ github.sha }}
468484
- name: Enforce Guix primary / Nix fallback
469485
run: |
470486
HAS_GUIX=$(find . -name "*.scm" -o -name ".guix-channel" -o -name "guix.scm" 2>/dev/null | head -1)
@@ -492,7 +508,15 @@ jobs:
492508
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
493509
with:
494510
repository: ${{ github.repository }}
495-
ref: ${{ github.ref }}
511+
# Pin to the concrete event SHA (the PR merge commit on
512+
# pull_request, the pushed commit on push). Do NOT use
513+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
514+
# pull_request, github.ref is the named merge ref
515+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
516+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
517+
# governance jobs on every PR estate-wide. github.sha resolves to the
518+
# same merge commit but is always fetchable.
519+
ref: ${{ github.sha }}
496520
- name: Security checks
497521
run: |
498522
FAILED=false
@@ -723,7 +747,15 @@ jobs:
723747
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
724748
with:
725749
repository: ${{ github.repository }}
726-
ref: ${{ github.ref }}
750+
# Pin to the concrete event SHA (the PR merge commit on
751+
# pull_request, the pushed commit on push). Do NOT use
752+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
753+
# pull_request, github.ref is the named merge ref
754+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
755+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
756+
# governance jobs on every PR estate-wide. github.sha resolves to the
757+
# same merge commit but is always fetchable.
758+
ref: ${{ github.sha }}
727759
- name: Check file permissions
728760
run: |
729761
find . -type f -perm /111 -name "*.sh" | head -10 || true
@@ -772,7 +804,15 @@ jobs:
772804
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
773805
with:
774806
repository: ${{ github.repository }}
775-
ref: ${{ github.ref }}
807+
# Pin to the concrete event SHA (the PR merge commit on
808+
# pull_request, the pushed commit on push). Do NOT use
809+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
810+
# pull_request, github.ref is the named merge ref
811+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
812+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
813+
# governance jobs on every PR estate-wide. github.sha resolves to the
814+
# same merge commit but is always fetchable.
815+
ref: ${{ github.sha }}
776816
- name: RFC 9116 security.txt validation
777817
run: |
778818
SECTXT=""
@@ -830,7 +870,15 @@ jobs:
830870
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
831871
with:
832872
repository: ${{ github.repository }}
833-
ref: ${{ github.ref }}
873+
# Pin to the concrete event SHA (the PR merge commit on
874+
# pull_request, the pushed commit on push). Do NOT use
875+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
876+
# pull_request, github.ref is the named merge ref
877+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
878+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
879+
# governance jobs on every PR estate-wide. github.sha resolves to the
880+
# same merge commit but is always fetchable.
881+
ref: ${{ github.sha }}
834882
- name: Check SPDX headers + permissions
835883
run: |
836884
failed=0
@@ -874,7 +922,15 @@ jobs:
874922
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
875923
with:
876924
repository: ${{ github.repository }}
877-
ref: ${{ github.ref }}
925+
# Pin to the concrete event SHA (the PR merge commit on
926+
# pull_request, the pushed commit on push). Do NOT use
927+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
928+
# pull_request, github.ref is the named merge ref
929+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
930+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
931+
# governance jobs on every PR estate-wide. github.sha resolves to the
932+
# same merge commit but is always fetchable.
933+
ref: ${{ github.sha }}
878934
path: caller
879935
- name: Checkout standards (for the check script)
880936
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
@@ -897,7 +953,15 @@ jobs:
897953
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
898954
with:
899955
repository: ${{ github.repository }}
900-
ref: ${{ github.ref }}
956+
# Pin to the concrete event SHA (the PR merge commit on
957+
# pull_request, the pushed commit on push). Do NOT use
958+
# `ref: ${{ github.ref }}`: in a reusable workflow called from a
959+
# pull_request, github.ref is the named merge ref
960+
# `refs/pull/<n>/merge`, which actions/checkout cannot fetch
961+
# ("couldn't find remote ref refs/pull/<n>/merge") — it broke 8/10
962+
# governance jobs on every PR estate-wide. github.sha resolves to the
963+
# same merge commit but is always fetchable.
964+
ref: ${{ github.sha }}
901965
path: caller
902966
- name: Checkout standards (for the check script)
903967
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

0 commit comments

Comments
 (0)