Skip to content

Commit 7cbbf75

Browse files
committed
ci(release): protect Cloudflare deployment dispatch
Gate Worker releases on protected-main environment policy and an exact-SHA successful Static Checks run. Reject invalid refs before checkout or dependency installation.
1 parent d88a5c7 commit 7cbbf75

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

.github/workflows/deploy-cloudflare.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,36 @@ concurrency:
88
cancel-in-progress: false
99

1010
permissions:
11+
actions: read
1112
contents: read
1213

1314
jobs:
1415
deploy:
1516
name: Deploy Workers
1617
runs-on: ubuntu-24.04
1718
timeout-minutes: 45
19+
environment: Production
1820
steps:
21+
- name: Require main
22+
run: test "$GITHUB_REF" = "refs/heads/main"
23+
24+
- name: Require successful static checks for this commit
25+
env:
26+
GH_TOKEN: ${{ github.token }}
27+
run: |
28+
successful_runs="$(gh api --method GET \
29+
"repos/${GITHUB_REPOSITORY}/actions/workflows/static-checks.yml/runs" \
30+
--field branch=main \
31+
--field event=push \
32+
--field head_sha="$GITHUB_SHA" \
33+
--field per_page=1 \
34+
--field status=success \
35+
--jq '.total_count')"
36+
if [ "$successful_runs" -lt 1 ]; then
37+
echo "Static Checks has not succeeded for $GITHUB_SHA on main." >&2
38+
exit 1
39+
fi
40+
1941
- name: Checkout reviewed release
2042
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2143
with:
@@ -25,9 +47,6 @@ jobs:
2547
with:
2648
release-sha: ${{ github.sha }}
2749

28-
- name: Require main
29-
run: test "$GITHUB_REF" = "refs/heads/main"
30-
3150
- name: Build Worker release
3251
run: >-
3352
pnpm exec turbo run build

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ declared workspace dependencies changed. Dispatch `Deploy Cloudflare` from
238238
gh workflow run deploy-cloudflare.yml --ref main
239239
```
240240

241+
The job runs under the protected `Production` environment, rejects non-`main`
242+
dispatches before checkout, and requires a successful `Static Checks` push run
243+
for the exact release commit before installing dependencies or accessing
244+
deployment credentials.
245+
241246
The workflow builds the four Workers once, binds the reviewed commit SHA into
242247
each deployment, and publishes agent, webhooks, preview proxy, then gateway.
243248
Gateway goes last so public traffic sees the new backend only after its service

0 commit comments

Comments
 (0)