Skip to content

Commit 56e38ab

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 56e38ab

1 file changed

Lines changed: 22 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

0 commit comments

Comments
 (0)