11name : Deploy Workers
22
3+ # Fully automated production deploy. Runs after "Static Checks" succeeds on main —
4+ # no manual step required. `workflow_dispatch` is kept only as a manual fallback.
5+ # The worker chain (agent → gateway → webhooks → preview-proxy) is the Daytona
6+ # backend; the web deploy runs independently and self-skips until its NEXT_PUBLIC
7+ # vars are configured (so a missing web var never blocks the backend cutover).
38on :
4- workflow_dispatch :
5- inputs :
6- confirm_production_deploy :
7- description : Type "deploy Cheatcode V2 to production" to approve production deployment.
8- required : true
9- type : string
9+ workflow_run :
10+ workflows : ["Static Checks"]
11+ types : [completed]
12+ workflow_dispatch : {}
1013
1114permissions :
1215 contents : read
1316
1417concurrency :
15- group : production-workers
18+ group : production-deploy
1619 cancel-in-progress : false
1720
1821jobs :
19- prepare-production :
20- if : github.event.inputs.confirm_production_deploy == 'deploy Cheatcode V2 to production'
21- runs-on : ubuntu-latest
22- environment : production
23- steps :
24- - uses : actions/checkout@v4
25- - uses : pnpm/action-setup@v4
26- with :
27- version : 10.33.2
28- - uses : actions/setup-node@v4
29- with :
30- node-version : 22
31- cache : pnpm
32- - run : pnpm install --frozen-lockfile
33- - run : pnpm typecheck:scripts
34-
3522 deploy-agent :
23+ # Only on a successful Static Checks run on main, or a manual dispatch.
24+ if : ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') }}
3625 runs-on : ubuntu-latest
37- needs : prepare-production
3826 environment : production
3927 steps :
4028 - uses : actions/checkout@v4
29+ with :
30+ ref : ${{ github.event.workflow_run.head_sha || github.sha }}
4131 - uses : pnpm/action-setup@v4
4232 with :
4333 version : 10.33.2
@@ -55,11 +45,13 @@ jobs:
5545 command : deploy
5646
5747 deploy-gateway :
58- runs-on : ubuntu-latest
5948 needs : deploy-agent
49+ runs-on : ubuntu-latest
6050 environment : production
6151 steps :
6252 - uses : actions/checkout@v4
53+ with :
54+ ref : ${{ github.event.workflow_run.head_sha || github.sha }}
6355 - uses : pnpm/action-setup@v4
6456 with :
6557 version : 10.33.2
@@ -76,12 +68,14 @@ jobs:
7668 workingDirectory : apps/gateway-worker
7769 command : deploy
7870
79- deploy-web :
80- runs-on : ubuntu-latest
71+ deploy-webhooks :
8172 needs : deploy-gateway
73+ runs-on : ubuntu-latest
8274 environment : production
8375 steps :
8476 - uses : actions/checkout@v4
77+ with :
78+ ref : ${{ github.event.workflow_run.head_sha || github.sha }}
8579 - uses : pnpm/action-setup@v4
8680 with :
8781 version : 10.33.2
@@ -90,20 +84,22 @@ jobs:
9084 node-version : 22
9185 cache : pnpm
9286 - run : pnpm install --frozen-lockfile
93- - run : pnpm --filter @cheatcode/web deploy
94- env :
95- CHEATCODE_PROD_DEPLOY_APPROVED : " true "
96- CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
97- CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
98- NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY : ${{ vars.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
99- NEXT_PUBLIC_POLAR_PRO_MONTHLY_PRODUCT_ID : ${{ vars.NEXT_PUBLIC_POLAR_PRO_MONTHLY_PRODUCT_ID }}
87+ - run : pnpm turbo build --filter= @cheatcode/webhooks-worker
88+ - uses : cloudflare/wrangler-action@v3
89+ with :
90+ apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
91+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
92+ workingDirectory : apps/webhooks-worker
93+ command : deploy
10094
101- deploy-webhooks :
95+ deploy-preview-proxy :
96+ needs : deploy-webhooks
10297 runs-on : ubuntu-latest
103- needs : deploy-web
10498 environment : production
10599 steps :
106100 - uses : actions/checkout@v4
101+ with :
102+ ref : ${{ github.event.workflow_run.head_sha || github.sha }}
107103 - uses : pnpm/action-setup@v4
108104 with :
109105 version : 10.33.2
@@ -112,20 +108,25 @@ jobs:
112108 node-version : 22
113109 cache : pnpm
114110 - run : pnpm install --frozen-lockfile
115- - run : pnpm turbo build --filter=@cheatcode/webhooks-worker
111+ - run : pnpm turbo build --filter=@cheatcode/preview-proxy
116112 - uses : cloudflare/wrangler-action@v3
117113 with :
118114 apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
119115 accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
120- workingDirectory : apps/webhooks-worker
116+ workingDirectory : apps/preview-proxy
121117 command : deploy
122118
123- deploy-preview-proxy :
119+ deploy-web :
120+ # Independent of the worker chain; self-skips until the NEXT_PUBLIC vars exist
121+ # so a missing web var can never block the backend cutover.
122+ needs : deploy-agent
123+ if : ${{ vars.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY != '' }}
124124 runs-on : ubuntu-latest
125- needs : deploy-webhooks
126125 environment : production
127126 steps :
128127 - uses : actions/checkout@v4
128+ with :
129+ ref : ${{ github.event.workflow_run.head_sha || github.sha }}
129130 - uses : pnpm/action-setup@v4
130131 with :
131132 version : 10.33.2
@@ -134,10 +135,10 @@ jobs:
134135 node-version : 22
135136 cache : pnpm
136137 - run : pnpm install --frozen-lockfile
137- - run : pnpm turbo build --filter= @cheatcode/preview-proxy
138- - uses : cloudflare/wrangler-action@v3
139- with :
140- apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
141- accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
142- workingDirectory : apps/preview-proxy
143- command : deploy
138+ - run : pnpm --filter @cheatcode/web deploy
139+ env :
140+ CHEATCODE_PROD_DEPLOY_APPROVED : " true "
141+ CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
142+ CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
143+ NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY : ${{ vars.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
144+ NEXT_PUBLIC_POLAR_PRO_MONTHLY_PRODUCT_ID : ${{ vars.NEXT_PUBLIC_POLAR_PRO_MONTHLY_PRODUCT_ID }}
0 commit comments