-
Notifications
You must be signed in to change notification settings - Fork 23
298 lines (280 loc) · 8.7 KB
/
ci.yml
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
name: CI
on:
merge_group:
pull_request:
types: ["opened", "edited", "reopened", "synchronize"]
push:
branches:
- main
jobs:
manypkg:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
pnpm install --frozen-lockfile
pnpm exec manypkg check
typecheck:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
pnpm install --frozen-lockfile
pnpm typecheck
oxlint:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
pnpm install --frozen-lockfile
pnpm build
pnpm oxlint -c .oxlintrc.json --quiet
lint:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
pnpm install --frozen-lockfile
pnpm build
pnpm run lint
format:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
pnpm install --frozen-lockfile
pnpm run format:ci
test:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
needs: [typecheck, format]
strategy:
matrix:
node: ["22"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 10
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
cache: "pnpm"
- run: |
pnpm install --frozen-lockfile
pnpm run test:unit:coverage
- uses: codecov/[email protected]
with:
# files: packages/**/coverage/cobertura-coverage.xmls
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
# accessibility:
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: '0'
# - uses: pnpm/[email protected]
# - name: Use Node.js
# uses: actions/[email protected]
# with:
# node-version: 22
# cache: 'pnpm'
# - run: pnpm install
# - run: pnpm run build
# - run: pnpm install
# - run: pnpm run test:a11y
build:
strategy:
matrix:
node: ["22"]
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
needs: [typecheck, format]
steps:
- uses: actions/checkout@v4 # v4.1.4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
- run: |
pnpm install --frozen-lockfile
pnpm run build
publint:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
pnpm install --frozen-lockfile
pnpm publint
deploy:
runs-on: ubuntu-24.04
env:
IMAGE_NAME: rg.fr-par.scw.cloud/ultraviolet/storybook
DEPLOYMENT_NAME: "storybook"
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
needs: [publint, typecheck, build]
steps:
- uses: actions/checkout@v4
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v5
- name: Export custom variables
run: |
SAFE_GITHUB_HEAD_REF_SLUG_URL=$(echo $GITHUB_HEAD_REF_SLUG_URL-$DEPLOYMENT_NAME | rev | cut -c-37 | rev | awk '{gsub(/^-/, ""); print}')
([[ $GITHUB_REF == 'refs/heads/main' ]] && echo "STORYBOOK_BRANCH_SLUG=main" || echo "STORYBOOK_BRANCH_SLUG=$SAFE_GITHUB_HEAD_REF_SLUG_URL") >> $GITHUB_ENV
- name: Start deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GH_TOKEN }}
env: ${{ env.DEPLOYMENT_NAME }}
ref: ${{ github.head_ref }}
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: rg.fr-par.scw.cloud/ultraviolet
username: nologin
password: ${{ secrets.SCW_SECRET_KEY }}
- name: Build
uses: docker/build-push-action@v6
env:
IMAGE: ${{ env.IMAGE_NAME }}:${{ env.STORYBOOK_BRANCH_SLUG }}
SOURCE_DATE_EPOCH: 0
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
with:
push: true
tags: ${{ env.IMAGE }}
file: Dockerfile
cache-from: type=local,src=/tmp/docs/.buildx-cache
cache-to: type=local,dest=/tmp/docs/.buildx-cache-new,mode=max
- name: Set scw_max_concurrency
id: set-max-concurrency
run: |
if [[ "${{ env.STORYBOOK_BRANCH_SLUG }}" == "main" ]]; then
echo "SCW_MAX_CONCURRENCY=30" >> $GITHUB_ENV
else
echo "SCW_MAX_CONCURRENCY=10" >> $GITHUB_ENV
fi
- name: Set scw_min_scale
id: set-min-scale
run: |
if [[ "${{ env.STORYBOOK_BRANCH_SLUG }}" == "main" ]]; then
echo "SCW_MIN_SCALE=1" >> $GITHUB_ENV
else
echo "SCW_MIN_SCALE=0" >> $GITHUB_ENV
fi
- name: Set scw_limit
id: set-cpu-limit
run: |
if [[ "${{ env.STORYBOOK_BRANCH_SLUG }}" == "main" ]]; then
echo "SCW_CPU_LIMIT=500" >> $GITHUB_ENV
echo "SCW_MEMORY_LIMIT=1024" >> $GITHUB_ENV
else
echo "SCW_CPU_LIMIT=250" >> $GITHUB_ENV
echo "SCW_MEMORY_LIMIT=256" >> $GITHUB_ENV
fi
- name: Deploy Serverless Container Scaleway
uses: philibea/[email protected]
id: deploy
with:
type: "deploy"
scw_dns: "storybook.ultraviolet.scaleway.com"
root_zone: ${{ env.STORYBOOK_BRANCH_SLUG == 'main' }}
scw_access_key: ${{ secrets.SCW_ACCESS_KEY }}
scw_secret_key: ${{ secrets.SCW_SECRET_KEY }}
scw_containers_namespace_id: ${{ secrets.SCW_CONTAINERS_NAMESPACE_ID }}
scw_environment_variables: "GITHUB=DEPLOY"
scw_registry: ${{ env.IMAGE_NAME }}:${{ env.STORYBOOK_BRANCH_SLUG }}
scw_min_scale: ${{ env.SCW_MIN_SCALE }}
scw_cpu_limit: ${{ env.SCW_CPU_LIMIT }}
scw_max_concurrency: ${{ env.SCW_MAX_CONCURRENCY }}
scw_sandbox: "v2"
scw_memory_limit: ${{ env.SCW_MEMORY_LIMIT }}
- name: Update deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
env: ${{ env.DEPLOYMENT_NAME }}
token: ${{ secrets.GH_TOKEN }}
auto_inactive: true
# This will now be automatically handled by github with the auto_inactive
override: false
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.deploy.outputs.url }}
- name: Move cache
run: |
rm -rf /tmp/docs/.buildx-cache
mv /tmp/docs/.buildx-cache-new /tmp/docs/.buildx-cache