Skip to content

Commit edff2e7

Browse files
authored
ci: gate manual staging on verified main (#27)
* ci: gate manual staging on verified main * test: harden staging gate contract
1 parent 5de7beb commit edff2e7

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎.github/workflows/staging-e2e.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
workflow_dispatch:
88

99
permissions:
10+
# Manual dispatch queries workflow runs for the selected main commit.
11+
actions: read
1012
contents: read
1113

1214
concurrency:
@@ -32,6 +34,20 @@ jobs:
3234
persist-credentials: false
3335
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
3436

37+
- name: Verify selected commit passed the quality workflow
38+
if: github.event_name == 'workflow_dispatch'
39+
env:
40+
GH_TOKEN: ${{ github.token }}
41+
shell: bash
42+
run: |
43+
successful_runs="$(gh api \
44+
"repos/${GITHUB_REPOSITORY}/actions/workflows/deploy.yml/runs?head_sha=${GITHUB_SHA}&event=push&status=success&per_page=1" \
45+
--jq '.workflow_runs | length')"
46+
if [ "$successful_runs" -ne 1 ]; then
47+
echo "::error::The selected main commit has no successful push run of Build and Push Docker Image"
48+
exit 1
49+
fi
50+
3551
- name: Set up Node
3652
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
3753
with:

‎src/test/runtime-contracts.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ describe('runtime integration contracts', () => {
2525
const workflow = readProjectFile('.github/workflows/staging-e2e.yml');
2626
expect(workflow).not.toContain('actions/upload-artifact');
2727
expect(workflow).not.toContain('test-results/**/*.webm');
28+
expect(workflow).toContain('actions: read');
29+
expect(workflow).toContain('Verify selected commit passed the quality workflow');
30+
expect(workflow).toContain("if: github.event_name == 'workflow_dispatch'");
31+
expect(workflow).toContain('head_sha=${GITHUB_SHA}&event=push&status=success');
32+
expect(workflow).toContain('if [ "$successful_runs" -ne 1 ]');
33+
expect(workflow).toContain('exit 1');
2834
});
2935

3036
it('keeps pull-request browser checks separate from Docker publication', () => {

0 commit comments

Comments
 (0)