-
-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (132 loc) · 5.06 KB
/
Copy pathfrontend-deploy.yml
File metadata and controls
158 lines (132 loc) · 5.06 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Deploy Frontend
permissions:
contents: read
on:
push:
branches: [main]
paths: ['frontend/**']
release:
types: [published]
concurrency:
group: frontend-deploy-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: frontend
jobs:
typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run type check
run: npm run check
deploy-staging:
name: Deploy to Staging
needs: typecheck
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: staging
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build for staging
run: npm run build
env:
VITE_API_URL: https://api-staging.skyreader.app
# Merge recently-served /_app/immutable/* assets from the live site into this
# build so still-open old tabs can keep lazy-loading their chunks after deploy.
- name: Retain previous deploys' immutable assets
run: node scripts/retain-immutable-assets.mjs build https://staging.skyreader.app
env:
RETAIN_MAX_AGE_DAYS: 7
- name: Deploy to Cloudflare Pages (staging)
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy --project-name=skyreader-staging --commit-dirty=true
workingDirectory: frontend
deploy-staging-prod:
name: Deploy Staging (Prod Backend)
needs: typecheck
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: staging
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build for staging-prod
run: npm run build
env:
VITE_API_URL: https://api.skyreader.app
# See deploy-staging — keep old immutable chunks servable for open tabs.
- name: Retain previous deploys' immutable assets
run: node scripts/retain-immutable-assets.mjs build https://staging-prod.skyreader.app
env:
RETAIN_MAX_AGE_DAYS: 7
- name: Deploy to Cloudflare Pages (staging-prod)
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy --project-name=skyreader-staging-prod --commit-dirty=true
workingDirectory: frontend
deploy-production:
name: Deploy to Production
needs: typecheck
if: github.event_name == 'release'
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build for production
run: npm run build
env:
VITE_API_URL: https://api.skyreader.app
# Merge recently-served /_app/immutable/* assets from the live site into this
# build so still-open old tabs (e.g. long-lived iOS PWAs) keep lazy-loading
# their chunks after deploy. Default retention: 30 days since last shipped.
- name: Retain previous deploys' immutable assets
run: node scripts/retain-immutable-assets.mjs build https://skyreader.app
- name: Deploy to Cloudflare Pages (production)
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy --project-name=skyreader --branch=main --commit-dirty=true
workingDirectory: frontend