@@ -126,6 +126,7 @@ jobs:
126126 env :
127127 CHECKOUT_REPO : ${{ github.repository }}
128128 CHECKOUT_REF : ${{ inputs.target_ref || github.sha }}
129+ CHECKOUT_EVENT_REF : ${{ github.ref }}
129130 CHECKOUT_FALLBACK_REF : ${{ github.sha }}
130131 GITHUB_EVENT_NAME : ${{ github.event_name }}
131132 run : |
@@ -152,12 +153,29 @@ jobs:
152153 sleep 5
153154 done
154155 }
155- if fetch_checkout_ref "$CHECKOUT_REF"; then
156+
157+ # Manual release-gate runs commonly validate the workflow ref's exact SHA.
158+ # Fetch the branch/tag ref first so GitHub does not have to negotiate an
159+ # arbitrary SHA fetch, then verify the resolved commit stayed pinned.
160+ checkout_ref="$CHECKOUT_REF"
161+ requested_sha=""
162+ if [[ "$CHECKOUT_REF" =~ ^[0-9a-f]{40}$ ]]; then
163+ requested_sha="$CHECKOUT_REF"
164+ if [[
165+ "$GITHUB_EVENT_NAME" == "workflow_dispatch" &&
166+ "$CHECKOUT_REF" == "$CHECKOUT_FALLBACK_REF" &&
167+ -n "$CHECKOUT_EVENT_REF"
168+ ]]; then
169+ checkout_ref="$CHECKOUT_EVENT_REF"
170+ fi
171+ fi
172+
173+ if fetch_checkout_ref "$checkout_ref"; then
156174 :
157175 else
158176 fetch_status="$?"
159177 if [ "$fetch_status" = "124" ] || [ "$fetch_status" = "137" ]; then
160- echo "::error::checkout fetch for '$CHECKOUT_REF ' timed out"
178+ echo "::error::checkout fetch for '$checkout_ref ' timed out"
161179 exit "$fetch_status"
162180 fi
163181 if [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ] || [ "$CHECKOUT_REF" = "$CHECKOUT_FALLBACK_REF" ]; then
@@ -166,6 +184,15 @@ jobs:
166184 echo "::warning::workflow_dispatch target_ref '$CHECKOUT_REF' is unavailable; falling back to head SHA '$CHECKOUT_FALLBACK_REF'"
167185 fetch_checkout_ref "$CHECKOUT_FALLBACK_REF"
168186 fi
187+
188+ if [ -n "$requested_sha" ]; then
189+ resolved_sha="$(git -C "$GITHUB_WORKSPACE" rev-parse refs/remotes/origin/checkout)"
190+ if [ "$resolved_sha" != "$requested_sha" ]; then
191+ echo "::error::checkout ref '$checkout_ref' resolved to '$resolved_sha'," \
192+ "expected '$requested_sha'" >&2
193+ exit 1
194+ fi
195+ fi
169196 git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
170197
171198 - name : Resolve checkout SHA
0 commit comments