-
Notifications
You must be signed in to change notification settings - Fork 1
338 lines (309 loc) · 14.8 KB
/
podman.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
name: Podman build & deploy
on:
push:
branches:
- develop
- main
tags:
- '*'
workflow_dispatch:
release:
types: [created]
jobs:
deploy-test:
name: Deploy to test environment
environment: Test
runs-on: tst
# this job runs only on commits to the develop branch or when manually triggered for a branch other than main
if: github.ref == 'refs/heads/develop' || (github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main')
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
# Variables
AML_ALLOWED_HOSTS: ${{ vars.AML_ALLOWED_HOSTS }}
AML_CORS_ORIGIN_WHITELIST: ${{ vars.AML_CORS_ORIGIN_WHITELIST }}
CSRF_TRUSTED_ORIGINS: ${{ vars.CSRF_TRUSTED_ORIGINS }}
AML_DEBUG: ${{ vars.AML_DEBUG }}
AML_LOCATION_PROVIDER: ${{ vars.AML_LOCATION_PROVIDER }}
AML_SUBPATH: ${{ vars.AML_SUBPATH }}
DJANGO_SETTINGS_MODULE: ${{ vars.DJANGO_SETTINGS_MODULE }}
SENTRY_ENVIRONMENT: "test"
SQL_DATABASE: ${{ vars.SQL_DATABASE }}
SQL_HOST: ${{ vars.SQL_HOST }}
SQL_PORT: ${{ vars.SQL_PORT }}
FRONTEND_API_ROOT: ${{ vars.FRONTEND_API_ROOT }}
FRONTEND_EXPERIMENT_SLUG: ${{ vars.FRONTEND_EXPERIMENT_SLUG }}
FRONTEND_AML_HOME: ${{ vars.FRONTEND_AML_HOME }}
FRONTEND_HTML_PAGE_TITLE: ${{ vars.FRONTEND_HTML_PAGE_TITLE }}
FRONTEND_HTML_FAVICON: ${{ vars.FRONTEND_HTML_FAVICON || '' }}
FRONTEND_LOGO_URL: ${{ vars.FRONTEND_LOGO_URL || '' }}
FRONTEND_HTML_OG_DESCRIPTION: ${{ vars.FRONTEND_HTML_OG_DESCRIPTION || '' }}
FRONTEND_HTML_OG_IMAGE: ${{ vars.FRONTEND_HTML_OG_IMAGE || '' }}
FRONTEND_HTML_OG_TITLE: ${{ vars.FRONTEND_HTML_OG_TITLE || '' }}
FRONTEND_HTML_OG_URL: ${{ vars.FRONTEND_HTML_OG_URL || '' }}
FRONTEND_HTML_BODY_CLASS: ${{ vars.FRONTEND_HTML_BODY_CLASS || '' }}
# Secrets
AML_SECRET_KEY: ${{ secrets.AML_SECRET_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SQL_USER: ${{ secrets.SQL_USER }}
SQL_PASSWORD: ${{ secrets.SQL_PASSWORD }}
FRONTEND_SENTRY_DSN: ${{ secrets.FRONTEND_SENTRY_DSN }}
DJANGO_SUPERUSER_USERNAME: ${{ secrets.DJANGO_SUPERUSER_USERNAME }}
DJANGO_SUPERUSER_PASSWORD: ${{ secrets.DJANGO_SUPERUSER_PASSWORD }}
DJANGO_SUPERUSER_EMAIL: ${{ secrets.DJANGO_SUPERUSER_EMAIL }}
# Prevent podman services from exiting after startup
RUNNER_TRACKING_ID: ""
steps:
- uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "VITE_API_ROOT=$FRONTEND_API_ROOT" >> .env
echo "VITE_EXPERIMENT_SLUG=$FRONTEND_EXPERIMENT_SLUG" >> .env
echo "VITE_AML_HOME=$FRONTEND_AML_HOME" >> .env
echo "VITE_LOGO_URL=$FRONTEND_LOGO_URL" >> .env
echo "VITE_HTML_FAVICON=$FRONTEND_HTML_FAVICON" >> .env
echo "VITE_HTML_PAGE_TITLE=$FRONTEND_HTML_PAGE_TITLE" >> .env
echo "VITE_HTML_OG_DESCRIPTION=$FRONTEND_HTML_OG_DESCRIPTION" >> .env
echo "VITE_HTML_OG_IMAGE=$FRONTEND_HTML_OG_IMAGE" >> .env
echo "VITE_HTML_OG_TITLE=$FRONTEND_HTML_OG_TITLE" >> .env
echo "VITE_HTML_OG_URL=$FRONTEND_HTML_OG_URL" >> .env
echo "VITE_HTML_BODY_CLASS=$FRONTEND_HTML_BODY_CLASS" >> .env
echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env
cp .env frontend/.env
- name: Build Podman images
run: podman-compose -f docker-compose-deploy.yml build
- name: Shut down running containers
run: podman compose -f docker-compose-deploy.yml down
- name: Deploy Podman images
run: podman-compose -f docker-compose-deploy.yml up -d
- name: Notify Sentry of new release
run: |
curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \
-H "Authorization: Bearer ${{ secrets.SENTRY_AUTH_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"version": "${{ github.sha }}",
"refs": [{
"repository": "Amsterdam-Music-Lab/MUSCLE",
"commit": "${{ github.sha }}"
}],
"projects": ["muscle-frontend", "muscle-backend"],
"environment": "test"
}'
- name: Prune old images
run: podman image prune -a -f
- name: Check Podman images
run: podman-compose -f docker-compose-deploy.yml ps
- name: Check logs
run: podman-compose -f docker-compose-deploy.yml logs
backup-acceptance:
name: Backup acceptance database before deployment
# this job runs only on commits to the main branch, tags, or when manually triggered for the main branch
if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
uses: ./.github/workflows/db-backup-template.yml
with:
runner: ACC
deploy-acceptance:
name: Deploy to acceptance environment
environment: Acceptance
runs-on: ACC
needs: backup-acceptance
# this job runs only on commits to the main branch, tags, or when manually triggered for the main branch
if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
# Variables
AML_ALLOWED_HOSTS: ${{ vars.AML_ALLOWED_HOSTS }}
AML_CORS_ORIGIN_WHITELIST: ${{ vars.AML_CORS_ORIGIN_WHITELIST }}
AML_DEBUG: ${{ vars.AML_DEBUG }}
AML_LOCATION_PROVIDER: ${{ vars.AML_LOCATION_PROVIDER }}
AML_SUBPATH: ${{ vars.AML_SUBPATH }}
DJANGO_SETTINGS_MODULE: ${{ vars.DJANGO_SETTINGS_MODULE }}
SENTRY_ENVIRONMENT: "acceptance"
SQL_DATABASE: ${{ vars.SQL_DATABASE }}
SQL_HOST: ${{ vars.SQL_HOST }}
SQL_PORT: ${{ vars.SQL_PORT }}
FRONTEND_API_ROOT: ${{ vars.FRONTEND_API_ROOT }}
FRONTEND_EXPERIMENT_SLUG: ${{ vars.FRONTEND_EXPERIMENT_SLUG }}
FRONTEND_AML_HOME: ${{ vars.FRONTEND_AML_HOME }}
FRONTEND_HTML_PAGE_TITLE: ${{ vars.FRONTEND_HTML_PAGE_TITLE }}
FRONTEND_HTML_FAVICON: ${{ vars.FRONTEND_HTML_FAVICON || '' }}
FRONTEND_LOGO_URL: ${{ vars.FRONTEND_LOGO_URL || '' }}
FRONTEND_HTML_OG_DESCRIPTION: ${{ vars.FRONTEND_HTML_OG_DESCRIPTION || '' }}
FRONTEND_HTML_OG_IMAGE: ${{ vars.FRONTEND_HTML_OG_IMAGE || '' }}
FRONTEND_HTML_OG_TITLE: ${{ vars.FRONTEND_HTML_OG_TITLE || '' }}
FRONTEND_HTML_OG_URL: ${{ vars.FRONTEND_HTML_OG_URL || '' }}
FRONTEND_HTML_BODY_CLASS: ${{ vars.FRONTEND_HTML_BODY_CLASS || '' }}
# Secrets
AML_SECRET_KEY: ${{ secrets.AML_SECRET_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SQL_USER: ${{ secrets.SQL_USER }}
SQL_PASSWORD: ${{ secrets.SQL_PASSWORD }}
FRONTEND_SENTRY_DSN: ${{ secrets.FRONTEND_SENTRY_DSN }}
DJANGO_SUPERUSER_USERNAME: ${{ secrets.DJANGO_SUPERUSER_USERNAME }}
DJANGO_SUPERUSER_PASSWORD: ${{ secrets.DJANGO_SUPERUSER_PASSWORD }}
DJANGO_SUPERUSER_EMAIL: ${{ secrets.DJANGO_SUPERUSER_EMAIL }}
# Prevent podman services from exiting after startup
RUNNER_TRACKING_ID: ""
steps:
- uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "VITE_API_ROOT=$FRONTEND_API_ROOT" >> .env
echo "VITE_EXPERIMENT_SLUG=$FRONTEND_EXPERIMENT_SLUG" >> .env
echo "VITE_AML_HOME=$FRONTEND_AML_HOME" >> .env
echo "VITE_LOGO_URL=$FRONTEND_LOGO_URL" >> .env
echo "VITE_HTML_FAVICON=$FRONTEND_HTML_FAVICON" >> .env
echo "VITE_HTML_PAGE_TITLE=$FRONTEND_HTML_PAGE_TITLE" >> .env
echo "VITE_HTML_OG_DESCRIPTION=$FRONTEND_HTML_OG_DESCRIPTION" >> .env
echo "VITE_HTML_OG_IMAGE=$FRONTEND_HTML_OG_IMAGE" >> .env
echo "VITE_HTML_OG_TITLE=$FRONTEND_HTML_OG_TITLE" >> .env
echo "VITE_HTML_OG_URL=$FRONTEND_HTML_OG_URL" >> .env
echo "VITE_HTML_BODY_CLASS=$FRONTEND_HTML_BODY_CLASS" >> .env
echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env
cp .env frontend/.env
- name: Build Podman images
run: podman-compose -f docker-compose-deploy.yml build
- name: Shut down running containers
run: podman compose -f docker-compose-deploy.yml down
- name: Deploy Podman images
run: podman-compose -f docker-compose-deploy.yml up -d
- name: Notify Sentry of new release
run: |
curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \
-H "Authorization: Bearer ${{ secrets.SENTRY_AUTH_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"version": "${{ github.sha }}",
"refs": [{
"repository": "Amsterdam-Music-Lab/MUSCLE",
"commit": "${{ github.sha }}"
}],
"projects": ["muscle-frontend", "muscle-backend"],
"environment": "acceptance"
}'
- name: Prune old images
run: podman image prune -a -f
- name: Check Podman images
run: podman-compose -f docker-compose-deploy.yml ps
- name: Check logs
run: podman-compose -f docker-compose-deploy.yml logs
backup-production:
name: Backup production database before deployment
# this job runs only on tags or when a release is created, or when manually triggered for a tag
if: github.ref == 'refs/tags/*' || github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/tags/*')
uses: ./.github/workflows/db-backup-template.yml
with:
runner: PRD
deploy-production:
name: Deploy to production environment
environment: Production
runs-on: PRD
needs: backup-production
# this job runs only on tags or when a release is created, or when manually triggered for a tag
if: github.ref == 'refs/tags/*' || github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/tags/*')
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
# Variables
AML_ALLOWED_HOSTS: ${{ vars.AML_ALLOWED_HOSTS }}
AML_CORS_ORIGIN_WHITELIST: ${{ vars.AML_CORS_ORIGIN_WHITELIST }}
AML_DEBUG: ${{ vars.AML_DEBUG }}
AML_LOCATION_PROVIDER: ${{ vars.AML_LOCATION_PROVIDER }}
AML_SUBPATH: ${{ vars.AML_SUBPATH }}
DJANGO_SETTINGS_MODULE: ${{ vars.DJANGO_SETTINGS_MODULE }}
SENTRY_ENVIRONMENT: "production"
SQL_DATABASE: ${{ vars.SQL_DATABASE }}
SQL_HOST: ${{ vars.SQL_HOST }}
SQL_PORT: ${{ vars.SQL_PORT }}
FRONTEND_API_ROOT: ${{ vars.FRONTEND_API_ROOT }}
FRONTEND_EXPERIMENT_SLUG: ${{ vars.FRONTEND_EXPERIMENT_SLUG }}
FRONTEND_AML_HOME: ${{ vars.FRONTEND_AML_HOME }}
FRONTEND_HTML_PAGE_TITLE: ${{ vars.FRONTEND_HTML_PAGE_TITLE }}
FRONTEND_HTML_FAVICON: ${{ vars.FRONTEND_HTML_FAVICON || '' }}
FRONTEND_LOGO_URL: ${{ vars.FRONTEND_LOGO_URL || '' }}
FRONTEND_HTML_OG_DESCRIPTION: ${{ vars.FRONTEND_HTML_OG_DESCRIPTION || '' }}
FRONTEND_HTML_OG_IMAGE: ${{ vars.FRONTEND_HTML_OG_IMAGE || '' }}
FRONTEND_HTML_OG_TITLE: ${{ vars.FRONTEND_HTML_OG_TITLE || '' }}
FRONTEND_HTML_OG_URL: ${{ vars.FRONTEND_HTML_OG_URL || '' }}
FRONTEND_HTML_BODY_CLASS: ${{ vars.FRONTEND_HTML_BODY_CLASS || '' }}
# Secrets
AML_SECRET_KEY: ${{ secrets.AML_SECRET_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SQL_USER: ${{ secrets.SQL_USER }}
SQL_PASSWORD: ${{ secrets.SQL_PASSWORD }}
FRONTEND_SENTRY_DSN: ${{ secrets.FRONTEND_SENTRY_DSN }}
DJANGO_SUPERUSER_USERNAME: ${{ secrets.DJANGO_SUPERUSER_USERNAME }}
DJANGO_SUPERUSER_PASSWORD: ${{ secrets.DJANGO_SUPERUSER_PASSWORD }}
DJANGO_SUPERUSER_EMAIL: ${{ secrets.DJANGO_SUPERUSER_EMAIL }}
# Prevent podman services from exiting after startup
RUNNER_TRACKING_ID: ""
steps:
- uses: actions/checkout@v4
- name: Create .env file
run: |
touch .env
echo "VITE_API_ROOT=$FRONTEND_API_ROOT" >> .env
echo "VITE_EXPERIMENT_SLUG=$FRONTEND_EXPERIMENT_SLUG" >> .env
echo "VITE_AML_HOME=$FRONTEND_AML_HOME" >> .env
echo "VITE_LOGO_URL=$FRONTEND_LOGO_URL" >> .env
echo "VITE_HTML_FAVICON=$FRONTEND_HTML_FAVICON" >> .env
echo "VITE_HTML_PAGE_TITLE=$FRONTEND_HTML_PAGE_TITLE" >> .env
echo "VITE_HTML_OG_DESCRIPTION=$FRONTEND_HTML_OG_DESCRIPTION" >> .env
echo "VITE_HTML_OG_IMAGE=$FRONTEND_HTML_OG_IMAGE" >> .env
echo "VITE_HTML_OG_TITLE=$FRONTEND_HTML_OG_TITLE" >> .env
echo "VITE_HTML_OG_URL=$FRONTEND_HTML_OG_URL" >> .env
echo "VITE_HTML_BODY_CLASS=$FRONTEND_HTML_BODY_CLASS" >> .env
echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env
cp .env frontend/.env
- name: Build Podman images
run: podman-compose -f docker-compose-deploy.yml build
- name: Shut down running containers
run: podman compose -f docker-compose-deploy.yml down
- name: Deploy Podman images
run: podman-compose -f docker-compose-deploy.yml up -d
- name: Notify Sentry of new release
run: |
curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \
-H "Authorization: Bearer ${{ secrets.SENTRY_AUTH_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"version": "${{ github.sha }}",
"refs": [{
"repository": "Amsterdam-Music-Lab/MUSCLE",
"commit": "${{ github.sha }}"
}],
"projects": ["muscle-frontend", "muscle-backend"],
"environment": "production"
}'
- name: Prune old images
run: podman image prune -a -f
- name: Check Podman images
run: podman-compose -f docker-compose-deploy.yml ps
e2e-acceptance:
name: E2E tests on acceptance environment
runs-on: ACC
if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
# needs to happen after the deployment to the acceptance environment
needs: deploy-acceptance
env:
BASE_URL: "https://acc.amsterdammusiclab.nl"
steps:
- uses: actions/checkout@v4
- name: Run E2E tests
run: cd e2e && bash run-tests
smoke-tests-production:
name: Smoke tests on production environment
runs-on: PRD
if: github.ref == 'refs/tags/*' || github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/tags/*')
# needs to happen after the deployment to the production environment
needs: deploy-production
env:
BASE_URL: "https://app.amsterdammusiclab.nl"
steps:
- uses: actions/checkout@v4
- name: Run smoke tests
run: cd e2e && bash run-tests --smoke