Skip to content

Commit 4e05f37

Browse files
Chore: deploy CommandGrid preview from main
Merge deploy automation after Scout merge-ready. Robin approved override despite missing Cloudflare repo secrets; post-merge workflow may fail until secrets are configured.
2 parents 4725492 + 4a6fcd3 commit 4e05f37

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- main
8+
workflow_dispatch:
89

910
jobs:
1011
check:
@@ -36,3 +37,55 @@ jobs:
3637

3738
- name: Cloudflare build
3839
run: npm run cf:build
40+
41+
deploy-preview:
42+
name: Deploy Cloudflare preview
43+
runs-on: ubuntu-latest
44+
needs: check
45+
if: >-
46+
${{
47+
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
48+
(github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
49+
}}
50+
concurrency:
51+
group: cloudflare-preview-deploy
52+
cancel-in-progress: false
53+
permissions:
54+
contents: read
55+
env:
56+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
57+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
58+
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_COMMANDGRID_DB: ${{ secrets.CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_COMMANDGRID_DB }}
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Setup Node
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: 22
67+
cache: npm
68+
69+
- name: Install
70+
run: npm ci
71+
72+
- name: Verify deploy configuration
73+
run: |
74+
missing=0
75+
for name in \
76+
CLOUDFLARE_API_TOKEN \
77+
CLOUDFLARE_ACCOUNT_ID \
78+
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_COMMANDGRID_DB
79+
do
80+
if [ -z "${!name}" ]; then
81+
echo "::error title=Missing deploy secret::${name} is required for Cloudflare preview deploy."
82+
missing=1
83+
fi
84+
done
85+
exit "${missing}"
86+
87+
- name: Cloudflare build
88+
run: npm run cf:build
89+
90+
- name: Deploy preview Worker
91+
run: npx wrangler deploy --env preview

docs/infra/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@ Expected results:
8686
- `/api/health`: all Phase 1 bindings present, AI Gateway configured mode
8787
- `/api/db-smoke`: `ok=true`, database `neondb`, user `neondb_owner`, schema `public`
8888

89+
## Automated preview deployment
90+
91+
GitHub Actions deploys the Cloudflare preview Worker after the CI `check` job succeeds on `push` to `main`. The deploy job runs:
92+
93+
```bash
94+
npm ci
95+
npm run cf:build
96+
npx wrangler deploy --env preview
97+
```
98+
99+
A manual `workflow_dispatch` run is also available, but the deploy job is guarded to run only from `refs/heads/main`. Pull requests and non-`main` branches never deploy.
100+
101+
Required GitHub Actions secrets/config for preview deploy:
102+
103+
- `CLOUDFLARE_API_TOKEN`: Cloudflare API token with permission to deploy the `commandgrid-preview` Worker and read/write the configured preview resources as required by Wrangler.
104+
- `CLOUDFLARE_ACCOUNT_ID`: Cloudflare account ID used by Wrangler during non-interactive deploys.
105+
- `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_COMMANDGRID_DB`: deploy-time Hyperdrive local connection string for the `COMMANDGRID_DB` binding. Use the safe preview/deploy equivalent of `COMMANDGRID_DATABASE_URL`; never commit or print the value.
106+
107+
If any required secret is missing, the deploy job fails during the `Verify deploy configuration` step with the missing secret name only. Secret values are never printed.
108+
109+
This automation targets only the `preview` Wrangler environment (`commandgrid-preview`). It does not deploy production.
110+
89111
## Deployment caveats
90112

91113
OpenNext/Cloudflare requires a local Hyperdrive emulation connection string during build/deploy. Use the local secret only:

0 commit comments

Comments
 (0)