-
Notifications
You must be signed in to change notification settings - Fork 1
415 lines (350 loc) · 15.9 KB
/
review-app.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
name: Manage review apps
on:
pull_request_target:
types: [closed]
branches: [main]
workflow_dispatch:
inputs:
pull_request_number:
description: 'Numéro de la pull request'
required: true
type: number
action_type:
description: 'Action'
required: true
type: choice
options:
- Créer
- Mettre à jour
- Supprimer
env:
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
ORGA_ID: ${{ secrets.CLEVER_ORG }}
PR_NAME: pr${{ github.event.inputs.pull_request_number }}
MAILER_HOST: ${{ secrets.MAILER_HOST }}
MAILER_PORT: ${{ secrets.MAILER_PORT }}
MAILER_USER: ${{ secrets.MAILER_USER }}
MAILER_PASSWORD: ${{ secrets.MAILER_PASSWORD }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
jobs:
deploy-addons:
if: github.event.inputs.action_type == 'Créer'
runs-on: ubuntu-latest
steps:
- name: Install clever-tools
run: npm install -g clever-tools
- name: Create postgres addon
run: clever addon create postgresql-addon $PR_NAME-postgres --org $ORGA_ID --plan xxs_sml --region par
- name: Create redis addon
run: clever addon create redis-addon $PR_NAME-redis --org $ORGA_ID --plan s_mono --region par
deploy-api:
if: github.event.inputs.action_type == 'Créer'
needs: [deploy-addons]
runs-on: ubuntu-latest
environment:
name: pr${{ github.event.inputs.pull_request_number }}-api
url: https://pr${{ github.event.inputs.pull_request_number }}-api.cleverapps.io
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-api
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ steps.extract_branch.outputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Install clever-tools
run: npm install -g clever-tools
- name: Create the app
run: |
clever create $APP_ALIAS --type node --alias $APP_ALIAS --region par --org $ORGA_ID
clever service link-addon "Cellar staging" -a $APP_ALIAS
clever service link-addon "Configuration provider" -a $APP_ALIAS
clever service link-addon $PR_NAME-postgres -a $APP_ALIAS
clever service link-addon $PR_NAME-redis -a $APP_ALIAS
clever config update -a $APP_ALIAS --enable-zero-downtime --enable-cancel-on-push --enable-force-https
echo "List the app’s environment variables and export them"
clever env -a $APP_ALIAS | grep -v '^#' | tr -d '"' >> "$GITHUB_ENV"
- name: Set environment variables
run: |
clever env set AUTH_SECRET "secret" -a $APP_ALIAS
clever env set CC_HEALTH_CHECK_PATH "/" -a $APP_ALIAS
clever env set CC_OVERRIDE_BUILDCACHE '.:../.cache/puppeteer' -a $APP_ALIAS
clever env set CC_PRE_RUN_HOOK 'corepack yarn workspace $WORKSPACE migrate && corepack yarn workspace $WORKSPACE seed' -a $APP_ALIAS
clever env set CEREMA_API "https://api.cerema.fr" -a $APP_ALIAS
clever env set CEREMA_ENABLED "false" -a $APP_ALIAS
clever env set CEREMA_USERNAME "unused" -a $APP_ALIAS
clever env set CEREMA_PASSWORD "unused" -a $APP_ALIAS
clever env set DATABASE_ENV "development" -a $APP_ALIAS
clever env set DATABASE_URL $POSTGRESQL_ADDON_URI -a $APP_ALIAS
clever env set E2E_EMAIL $E2E_EMAIL -a $APP_ALIAS
clever env set E2E_PASSWORD $E2E_PASSWORD -a $APP_ALIAS
clever env set HOST "https://$APP_ALIAS.cleverapps.io" -a $APP_ALIAS
clever env set METABASE_TOKEN "unused" -a $APP_ALIAS
clever env set PORT "8080" -a $APP_ALIAS
clever env set S3_ACCESS_KEY_ID $CELLAR_ADDON_KEY_ID -a $APP_ALIAS
clever env set S3_BUCKET zerologementvacant -a $APP_ALIAS
clever env set S3_ENDPOINT "https://$CELLAR_ADDON_HOST" -a $APP_ALIAS
clever env set S3_REGION "cellar-c2" -a $APP_ALIAS
clever env set S3_SECRET_ACCESS_KEY $CELLAR_ADDON_KEY_SECRET -a $APP_ALIAS
clever env set SENTRY_ENABLED "false" -a $APP_ALIAS
clever env set TZ "Etc/UTC" -a $APP_ALIAS
clever env set WORKSPACE "@zerologementvacant/server" -a $APP_ALIAS
clever env set MAILER_HOST $MAILER_HOST -a $APP_ALIAS
clever env set MAILER_PORT $MAILER_PORT -a $APP_ALIAS
clever env set MAILER_USER $MAILER_USER -a $APP_ALIAS
clever env set MAILER_PASSWORD $MAILER_PASSWORD -a $APP_ALIAS
clever env set MAILER_PROVIDER "nodemailer" -a $APP_ALIAS
clever env set TEST_PASSWORD $TEST_PASSWORD -a $APP_ALIAS
- name: Scale up for deployment
run: clever scale --flavor M -a $APP_ALIAS
- name: Deploy the app
run: |
clever domain add $APP_ALIAS.cleverapps.io -a $APP_ALIAS
clever deploy -a $APP_ALIAS --same-commit-policy rebuild
- name: Scale down for the run
run: clever scale --flavor S -a $APP_ALIAS
deploy-queue:
if: github.event.inputs.action_type == 'Créer'
needs: [deploy-addons]
runs-on: ubuntu-latest
environment:
name: pr${{ github.event.inputs.pull_request_number }}-queue
url: https://pr${{ github.event.inputs.pull_request_number }}-queue.cleverapps.io
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-queue
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ steps.extract_branch.outputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Install clever-tools
run: npm install -g clever-tools
- name: Create the app
run: |
clever create $APP_ALIAS --type node --alias $APP_ALIAS --region par --org $ORGA_ID
clever service link-addon "Cellar staging" -a $APP_ALIAS
clever service link-addon "Configuration provider" -a $APP_ALIAS
clever service link-addon $PR_NAME-postgres -a $APP_ALIAS
clever service link-addon $PR_NAME-redis -a $APP_ALIAS
clever config update -a $APP_ALIAS --enable-zero-downtime --enable-cancel-on-push --enable-force-https
echo "List the app’s environment variables and export them"
clever env -a $APP_ALIAS | grep -v '^#' | tr -d '"' >> "$GITHUB_ENV"
- name: Set environment variables
run: |
clever env set API_HOST https://$PR_NAME-api.cleverapps.io/api -a $APP_ALIAS
clever env set AUTH_SECRET "secret" -a $APP_ALIAS
clever env set CC_HEALTH_CHECK_PATH "/" -a $APP_ALIAS
clever env set CC_OVERRIDE_BUILDCACHE '.:../.cache/puppeteer' -a $APP_ALIAS
clever env set DATABASE_URL $POSTGRESQL_ADDON_URI -a $APP_ALIAS
clever env set S3_ACCESS_KEY_ID $CELLAR_ADDON_KEY_ID -a $APP_ALIAS
clever env set S3_BUCKET zerologementvacant -a $APP_ALIAS
clever env set S3_ENDPOINT "https://$CELLAR_ADDON_HOST" -a $APP_ALIAS
clever env set S3_REGION "cellar-c2" -a $APP_ALIAS
clever env set S3_SECRET_ACCESS_KEY $CELLAR_ADDON_KEY_SECRET -a $APP_ALIAS
clever env set WORKSPACE "@zerologementvacant/queue" -a $APP_ALIAS
- name: Scale up for deployment
run: clever scale --flavor M -a $APP_ALIAS
- name: Deploy the app
run: |
clever domain add $APP_ALIAS.cleverapps.io -a $APP_ALIAS
clever deploy -a $APP_ALIAS --same-commit-policy rebuild
- name: Scale down for the run
run: clever scale --flavor M -a $APP_ALIAS
deploy-front:
if: github.event.inputs.action_type == 'Créer'
needs: [deploy-addons]
runs-on: ubuntu-latest
environment:
name: pr${{ github.event.inputs.pull_request_number }}-front
url: https://pr${{ github.event.inputs.pull_request_number }}-front.cleverapps.io
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-front
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ steps.extract_branch.outputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Install clever-tools
run: npm install -g clever-tools
- name: Create the app
run: |
clever create $APP_ALIAS --type static-apache --alias $APP_ALIAS --region par --org $ORGA_ID
clever config update -a $APP_ALIAS --enable-zero-downtime --enable-cancel-on-push --enable-force-https
echo "List the app’s environment variables and export them"
clever env -a $APP_ALIAS | grep -v '^#' | tr -d '"' >> "$GITHUB_ENV"
- name: Set environment variables
run: |
clever env set CC_OVERRIDE_BUILDCACHE "frontend/build/" -a $APP_ALIAS
clever env set CC_POST_BUILD_HOOK "ls -al $CC_OVERRIDE_BUILDCACHE" -a $APP_ALIAS
clever env set CC_PRE_BUILD_HOOK 'corepack enable && corepack yarn workspaces focus $WORKSPACE && corepack yarn workspaces foreach --from=$WORKSPACE -Rt run build' -a $APP_ALIAS
clever env set CC_WEBROOT "/frontend/build" -a $APP_ALIAS
clever env set REACT_APP_API_URL https://$PR_NAME-api.cleverapps.io -a $APP_ALIAS
clever env set REACT_APP_MATOMO_ENABLED "false" -a $APP_ALIAS
clever env set REACT_APP_MATOMO_SITE_ID "42" -a $APP_ALIAS
clever env set REACT_APP_MATOMO_URL_BASE "unused" -a $APP_ALIAS
clever env set WORKSPACE "@zerologementvacant/front" -a $APP_ALIAS
- name: Scale up for deployment
run: clever scale --flavor M -a $APP_ALIAS
- name: Deploy the app
run: |
clever domain add $APP_ALIAS.cleverapps.io -a $APP_ALIAS
clever deploy -a $APP_ALIAS --same-commit-policy rebuild
- name: Scale down for the run
run: clever scale --flavor XS -a $APP_ALIAS
update-api:
if: github.event.inputs.action_type == 'Mettre à jour'
runs-on: ubuntu-latest
environment:
name: pr${{ github.event.inputs.pull_request_number }}-api
url: https://pr${{ github.event.inputs.pull_request_number }}-api.cleverapps.io
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-api
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ steps.extract_branch.outputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Install clever-tools
run: npm install -g clever-tools
- name: Link app
run: clever link -o $ORGA_ID $APP_ALIAS
- name: Scale up for deployment
run: clever scale --flavor M -a $APP_ALIAS
- name: Update the app
run: clever deploy --force -a $APP_ALIAS --same-commit-policy rebuild
- name: Scale down for the run
run: clever scale --flavor S -a $APP_ALIAS
update-front:
if: github.event.inputs.action_type == 'Mettre à jour'
runs-on: ubuntu-latest
environment:
name: pr${{ github.event.inputs.pull_request_number }}-front
url: https://pr${{ github.event.inputs.pull_request_number }}-front.cleverapps.io
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-front
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ steps.extract_branch.outputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Install clever-tools
run: npm install -g clever-tools
- name: Link app
run: clever link -o $ORGA_ID $APP_ALIAS
- name: Scale up for deployment
run: clever scale --flavor M -a $APP_ALIAS
- name: Update the app
run: clever deploy --force -a $APP_ALIAS --same-commit-policy rebuild
- name: Scale down for the run
run: clever scale --flavor XS -a $APP_ALIAS
update-queue:
if: github.event.inputs.action_type == 'Mettre à jour'
runs-on: ubuntu-latest
environment:
name: pr${{ github.event.inputs.pull_request_number }}-queue
url: https://pr${{ github.event.inputs.pull_request_number }}-queue.cleverapps.io
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-queue
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ steps.extract_branch.outputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Install clever-tools
run: npm install -g clever-tools
- name: Link app
run: clever link -o $ORGA_ID $APP_ALIAS
- name: Scale up for deployment
run: clever scale --flavor M -a $APP_ALIAS
- name: Update the app
run: clever deploy --force -a $APP_ALIAS --same-commit-policy rebuild
- name: Scale down for the run
run: clever scale --flavor M -a $APP_ALIAS
delete-queue:
runs-on: ubuntu-latest
if: always() && (github.event.inputs.action_type == 'Supprimer' || (github.event_name == 'pull_request_target' && github.event.action == 'closed'))
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-queue
steps:
- name: Install clever-tools
run: npm install -g clever-tools
- name: Delete the app
run: |
clever link -o $ORGA_ID $APP_ALIAS
clever delete -a $APP_ALIAS --yes
delete-api:
runs-on: ubuntu-latest
if: always() && (github.event.inputs.action_type == 'Supprimer' || (github.event_name == 'pull_request_target' && github.event.action == 'closed'))
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-api
steps:
- name: Install clever-tools
run: npm install -g clever-tools
- name: Delete the app
run: |
clever link -o $ORGA_ID $APP_ALIAS
clever delete -a $APP_ALIAS --yes
delete-front:
runs-on: ubuntu-latest
if: always() && (github.event.inputs.action_type == 'Supprimer' || (github.event_name == 'pull_request_target' && github.event.action == 'closed'))
env:
APP_ALIAS: pr${{ github.event.inputs.pull_request_number }}-front
steps:
- name: Install clever-tools
run: npm install -g clever-tools
- name: Delete the app
run: |
clever link -o $ORGA_ID $APP_ALIAS
clever delete -a $APP_ALIAS --yes
delete-addons:
runs-on: ubuntu-latest
if: always() && (github.event.inputs.action_type == 'Supprimer' || (github.event_name == 'pull_request_target' && github.event.action == 'closed'))
steps:
- name: Install clever-tools
run: npm install -g clever-tools
- name: Delete the app
run: |
clever addon delete $PR_NAME-postgres -o $ORGA_ID --yes
clever addon delete $PR_NAME-redis -o $ORGA_ID --yes