-
Notifications
You must be signed in to change notification settings - Fork 4
49 lines (44 loc) · 2.35 KB
/
Copy pathdeploy.yml
File metadata and controls
49 lines (44 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Deploy Cloudflare production
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: read
concurrency:
group: hackweek-cloudflare
cancel-in-progress: false
jobs:
verify:
if: github.ref == 'refs/heads/master'
uses: ./.github/workflows/test.yml
deploy:
name: Deploy production
needs: verify
runs-on: ubuntu-latest
environment: hackweek-cloudflare
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24.19.0
cache: npm
- run: npm ci --no-audit --no-fund
- name: Validate required configuration
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
test -n "$CLOUDFLARE_API_TOKEN" || { echo 'Missing CLOUDFLARE_API_TOKEN'; exit 1; }
test "$CLOUDFLARE_ACCOUNT_ID" = '20d94f53c7cab0b469521b703ff1923c' || { echo 'Unexpected Cloudflare account'; exit 1; }
node -e "const c=require('./wrangler.production.json'); const videos=c.r2_buckets.find(x=>x.binding==='VIDEOS'); const workflow=c.workflows.find(x=>x.binding==='VIDEO_PROCESSING_WORKFLOW'); const container=c.containers.find(x=>x.class_name==='VideoProcessorContainer'); if (c.account_id !== '20d94f53c7cab0b469521b703ff1923c' || videos?.bucket_name !== 'hackweek-video-media-production' || workflow?.name !== 'hackweek-video-processing-production' || container?.name !== 'hackweek-video-processor-production' || container?.max_instances !== 5 || c.vars.VIDEO_PROCESSOR_CONCURRENCY !== '2') process.exit(1); for (const value of [c.d1_databases[0].database_id,c.r2_buckets[0].bucket_name,c.vars.APP_ORIGIN,c.vars.GOOGLE_REDIRECT_URI,c.vars.GOOGLE_CLIENT_ID]) if (!value || /replace.me/i.test(value) || value === '00000000-0000-0000-0000-000000000000') process.exit(1)"
- run: npm run build
- name: Apply expand-compatible D1 migrations
run: npx wrangler d1 migrations apply hackweek-db --remote --config wrangler.production.json
env: &cloudflare
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy Worker and static assets
run: npx wrangler deploy --config wrangler.production.json
env: *cloudflare