Skip to content

Commit 51a14e0

Browse files
authored
ci(release): add exact-SHA verify dispatch (#2309)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: B'Elanna (Squad) <tamirdresher@users.noreply.github.com> Copilot-Session: 995eea17-c356-4912-90ea-5e5b144e7ba9
1 parent 1f8daee commit 51a14e0

2 files changed

Lines changed: 34 additions & 9 deletions

File tree

‎.github/workflows/squad-release-verify.yml‎

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ name: Squad Release Verify
1717
# No skip labels and no SQUAD_*_CHECK repository variables are consulted here.
1818

1919
on:
20+
workflow_dispatch:
21+
inputs:
22+
sha:
23+
description: 'Full lowercase 40-hex commit SHA to verify (must equal the dispatched ref SHA)'
24+
required: true
25+
type: string
2026
workflow_call:
2127
inputs:
2228
source_sha:
@@ -60,7 +66,7 @@ permissions:
6066
contents: read
6167

6268
concurrency:
63-
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.source_sha || github.event.pull_request.head.sha }}
69+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.source_sha || inputs.sha || github.event.pull_request.head.sha }}
6470
cancel-in-progress: false
6571

6672
jobs:
@@ -69,12 +75,21 @@ jobs:
6975
runs-on: windows-latest
7076
timeout-minutes: 20
7177
env:
72-
SOURCE_SHA: ${{ inputs.source_sha || github.event.pull_request.head.sha }}
78+
SOURCE_SHA: ${{ inputs.source_sha || inputs.sha || github.event.pull_request.head.sha }}
79+
DISPATCH_SHA: ${{ inputs.sha }}
7380
EVIDENCE_DIR: ${{ github.workspace }}\evidence-windows
7481
steps:
82+
- name: Validate requested SHA
83+
shell: pwsh
84+
run: |
85+
if ($env:SOURCE_SHA -notmatch '^[0-9a-f]{40}$') { throw "sha must be a full lowercase 40-hex SHA, got '$env:SOURCE_SHA'" }
86+
if ($env:DISPATCH_SHA -and $env:GITHUB_SHA -cne $env:SOURCE_SHA) {
87+
throw "workflow_dispatch ref SHA $env:GITHUB_SHA != requested $env:SOURCE_SHA"
88+
}
89+
7590
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7
7691
with:
77-
ref: ${{ inputs.source_sha || github.event.pull_request.head.sha }}
92+
ref: ${{ inputs.source_sha || inputs.sha || github.event.pull_request.head.sha }}
7893
fetch-depth: 0
7994

8095
- name: Assert checkout is exactly the requested SHA
@@ -123,12 +138,22 @@ jobs:
123138
sdk_sha256: ${{ steps.pack.outputs.sdk_sha256 }}
124139
cli_sha256: ${{ steps.pack.outputs.cli_sha256 }}
125140
env:
126-
SOURCE_SHA: ${{ inputs.source_sha || github.event.pull_request.head.sha }}
141+
SOURCE_SHA: ${{ inputs.source_sha || inputs.sha || github.event.pull_request.head.sha }}
142+
DISPATCH_SHA: ${{ inputs.sha }}
127143
EVIDENCE_DIR: ${{ github.workspace }}/evidence
128144
steps:
145+
- name: Validate requested SHA
146+
run: |
147+
set -euo pipefail
148+
[[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::sha must be a full lowercase 40-hex SHA, got '$SOURCE_SHA'"; exit 1; }
149+
if [[ -n "$DISPATCH_SHA" && "$GITHUB_SHA" != "$SOURCE_SHA" ]]; then
150+
echo "::error::workflow_dispatch ref SHA $GITHUB_SHA != requested $SOURCE_SHA"
151+
exit 1
152+
fi
153+
129154
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7
130155
with:
131-
ref: ${{ inputs.source_sha || github.event.pull_request.head.sha }}
156+
ref: ${{ inputs.source_sha || inputs.sha || github.event.pull_request.head.sha }}
132157
fetch-depth: 0
133158

134159
- name: Assert checkout is exactly the requested SHA
@@ -212,9 +237,9 @@ jobs:
212237

213238
- name: "Gate: release policy (no label or variable bypass)"
214239
env:
215-
# pull_request: pending changesets are how a PR declares its changes — they must be
216-
# well-formed, not drained. workflow_call from squad-release.yml: drain is enforced.
217-
POLICY_MODE: ${{ github.event_name == 'pull_request' && 'ci' || 'release' }}
240+
# pull_request/workflow_dispatch: pending changesets must be well-formed, not drained.
241+
# workflow_call from squad-release.yml: drain is enforced before publication.
242+
POLICY_MODE: ${{ inputs.source_sha != '' && 'release' || 'ci' }}
218243
run: |
219244
set -euo pipefail
220245
node scripts/release/policy-gates.mjs "--mode=$POLICY_MODE" --json > "$EVIDENCE_DIR/policy-gates.json" || true

‎test/release-policy-changeset-drain.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('policy gate changeset-drain is branch/event-aware', () => {
8484

8585
it('squad-release-verify.yml derives the mode from the event instead of hard-coding release', () => {
8686
const wf = readFileSync(join(ROOT, '.github', 'workflows', 'squad-release-verify.yml'), 'utf8');
87-
expect(wf).toMatch(/POLICY_MODE: \$\{\{ github\.event_name == 'pull_request' && 'ci' \|\| 'release' \}\}/);
87+
expect(wf).toMatch(/POLICY_MODE: \$\{\{ inputs\.source_sha != '' && 'release' \|\| 'ci' \}\}/);
8888
expect(wf).toMatch(/policy-gates\.mjs "--mode=\$POLICY_MODE"/);
8989
expect(wf).not.toMatch(/policy-gates\.mjs --mode=release/);
9090
});

0 commit comments

Comments
 (0)