-
Notifications
You must be signed in to change notification settings - Fork 297
378 lines (343 loc) · 22.4 KB
/
testserver.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
name: Deploy to Testserver
on:
pull_request:
types: [labeled]
concurrency: test-servers
env:
RAW_URL: https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}
jobs:
# Get an up to date version of the label list. github.event.pull_request.labels seems to sometimes be outdated
# if the run was waiting for a while, which can cause duplicate deployments
get-labels:
runs-on: ubuntu-latest
outputs:
labels: ${{ steps.get-labels.outputs.result }}
steps:
- name: Get PR labels
id: get-labels
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
const labels = response.data
return labels.map(label => label.name)
# Check that the build job has run successfully before deploying
check-build-status:
needs: [ get-labels ]
runs-on: ubuntu-latest
# Only run workflow if the added label is a deploy label
if: contains(needs.get-labels.outputs.labels, 'deploy:artemis-test')
steps:
- name: Get latest successful build for branch
id: check_build
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.repository }}/actions/workflows/build.yml/runs?event=pull_request&status=success&head_sha=${{ github.event.pull_request.head.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Remove deployment-error label if new run is started
- uses: actions-ecosystem/action-remove-labels@v1
if: fromJSON(steps.check_build.outputs.data).total_count > 0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: |
deployment-error
# In case of invalid build status, remove deploy labels
- uses: actions-ecosystem/action-remove-labels@v1
if: fromJSON(steps.check_build.outputs.data).total_count == 0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: |
deploy:artemis-test1
deploy:artemis-test2
deploy:artemis-test3
deploy:artemis-test4
deploy:artemis-test5
deploy:artemis-test6
deploy:artemis-test7
deploy:artemis-test8
deploy:artemis-test9
deploy:artemis-test10
- name: Check if latest push had successful build
if: fromJSON(steps.check_build.outputs.data).total_count == 0
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '### ❌ Unable to deploy to test servers ❌\nThe docker build needs to run through before deploying.'
})
core.setFailed('The build needs to run through first. Please wait for the build to finish and then try again.')
# Check which test server to deploy to based on the label
filter-matrix:
needs: [ get-labels, check-build-status ]
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Commented out environments are not yet available and will be enabled in the future
#- environment: artemis-test1.artemis.cit.tum.de
# label-identifier: artemis-test1
# url: https://artemis-test1.artemis.cit.tum.de
# user: deployment
# hosts: artemis-test1.artemis.cit.tum.de
# folder: /opt/artemis
# host_keys: |
# artemis-test1.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDS+lFrN7hvzFjESxSQkmLbBdra9dWo33izxLRO2x5oTQwcbZA66Y3cQungIV460aQHwH+K0ALQuEc5EA7LegfFXo//t3kqXEALf0xRkO5tLnJEBpwnjpiOj8GFVIR8XOopKHf3zLo7/rmCPmdN0TKKigw9PcowB3Nf9TlpXvVtpkNTqnjwxfsLqvVjTf+8ji48Xe8zOhAH4zyJEc1KFM7XNdYYJPUctQyOoF+9QrTEW2GLYRkb2IqL8RDd09riUrjtsQJdoK21ATPC07j6XqGCgZxZQfmq4NlqEg2euQt45l0ZkVp3sQG70U0NkwKsLLhABWOzKDWvix7mJ/YDXCkk4Q8Badus1vIBAZYuTATfsEwXnQEnKTl8i4l7CE6U4PZLhwOgxcLBU9E3YKLjCsp8wfEV0n/wyoxXKUSH7Lb0jPQ4JMVUgNT5Rkdt0RE3YMWxVLrQNs6u33m2LrXt3lmiZsGpFa08RcjnSdFtHonL/CkwU00kckoMwRPgUniJKmM=
# artemis-test1.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMk4f5/x4grLMOY9jQCp3SfSjF81iWYRCbXJHBMWzG3TbQq9d2zW8bGCak5TGwPCDnjfBPRRSF57LZJlNaf3wPE=
# artemis-test1.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBGzlZUARYQBdq85FtCe4IALac1dSWoNsvQZmeCjPmS/
#- environment: artemis-test2.artemis.cit.tum.de
# label-identifier: artemis-test2
# url: https://artemis-test2.artemis.cit.tum.de
# user: deployment
# hosts: artemis-test2.artemis.cit.tum.de
# folder: /opt/artemis
# host_keys: |
# artemis-test2.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDUqNIPYUJBuItIfGzVu8jtpNWerFoqNq34cPU/+w5biwCrQA/RMIRt0H49ETc4vgc3rN85//FJ9j2x4jGfyS3jxj/ind6PX1QIBjGl09s2TFz53Z8OwcAw9iXJrtKqZGfxr8sbVfboDGa/kyr8E+YUJo+6bPusLQPSAJn8GUGgcNKHQSX7A4sEIeq2uU1RqGKDWJSxyECUxyubfNB6LCZd3ezEP1MPDnvhoF/5cEP4QxeTsVIkwIIAE8oVxNM7Ni8xqkl8sUM//SdzglFsK2gE5eSZ5OpQ5h/Cc3Oo1z7LnwlMwo8fGnhAcoUpDjuKD/2AdIhkyW0B4xUKbKVO94kVSuBUXErYqF4bHByGgjkzR0JTEwk5+shlUjoEA6DBxBO08CudJcTDUhk5+8fRwOzxfSTakr8sOfakgo7W6fBl3P4lHSdsd7VqKINcR3A9QYSXeiEeqliXnTkDSsZw4ux9JyuLle1DHPbTuH8f+vEosdxda+djm3FeijYTe4QS87k=
# artemis-test2.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBDRCF0zH3u38zVPNUhJI7zIDsXa3ONiU0GeCv/ybjawkh4alBPnlXtdH0cG1JPtR/Jz/gau92dcqiIFtqdDCDkg=
# artemis-test2.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMV70ACU6GdLtf1MwUklNltC78UoOPsasZruYh0Ord6n
#- environment: artemis-test3.artemis.cit.tum.de
# label-identifier: artemis-test3
# url: https://artemis-test3.artemis.cit.tum.de
# user: deployment
# hosts: artemis-test3.artemis.cit.tum.de
# folder: /opt/artemis
# host_keys: |
# artemis-test3.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC3zNbNkbYMUbNKCtVSa1GH7ovysowYQQHQK3owHbfjyKsaS6lTO2o16mMe3pu0+CwMdsJqBqn5Lt6M9HyCW74WwwWbOcUrcSqE/37hx5Ja2YzCwucTpvUCR3WVrmwBEYCoS5ZdQfFmyfVQtqjCCI5DdRk1wgY00eLoc8d6YOb6XnmMTs41WcyXFl8ffjhG3jMGlQILI8zhyZqnYB8HwadRAp8Oa6+DyGhOBAV5d3S0AZqjMKNoBGSAXCfs/nG3jBigxNCV7zeIjuhi2Ize/GY+gMcCrvWhjs/lXERII7RDIlcZogyN9+rGRX8X8okMoS1YONxzWPFb6XQajeDriESQ5txyHXpbFwcSLSU8DzleS9UZMah99knMs0Fyzu0q4rbCS1PtaAJfSOLjVgp67j3DNkXV+P5CZaSYI7hl377u0aTTHB5W3Myn7kXrNL2vjRk/mui+/Ds/+PPCJERWJAhCYp+CGj/itcOKPJqyfLL3ejzpqhRDzDTWCHU2cUnE2PE=
# artemis-test3.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBF3JQ7fPlW+Rua4JXCl4Dska45h4PhClWvmcFQHGA4H0bLEG+lVXuw5yuRk9lDD88pvzStFewk9EbmJ8Sja0zKo=
# artemis-test3.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGE67ADXnCgvbyJfqDAmSvegYwmCzfOyAUKBbJpwh7oU
- environment: artemis-test4.artemis.cit.tum.de
label-identifier: artemis-test4
url: https://artemis-test4.artemis.cit.tum.de
user: deployment
hosts: artemis-test4.artemis.cit.tum.de
folder: /opt/artemis
host_keys: |
artemis-test4.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwYFngAYWkI7yaf/6Ni81xCgWyh2gFlGPsUBq57iwROEQjfebTB8lWk2VfC3uCNXIEYB0IBQptPljRF2yQq+vUUeMerzXd5D/aeDmtS59f/z3W3ah3k3N7y5kFmBTGdvg53l+B34lQG6bEbB4McX8MhSUYdtAkp6Sc5EcxXiaDhcgGMCtXSMBJUrIGN+Is4AlWlqCGkL1KP+Y23rOaL3co+RppkcPDoKat8BZD2EbVBp9ZqqAVc+qIud/IMbTVZkhnaNoC0K33aoBLtauoTbYo/5kOlwFCDGM+NiNaXrOF5ANGJxX8WYoFXWVxxJFDVAm3x7ajZqydmkxWhPfUa9LIIEy2QbmeYvosfd8p/5STOQCHqE9dLHwjtin/vL1b0HmclIQUhrMVYMTeJNSCN9D2uRcU9U7Cz4qbX9s6/eCVjHfTkr+b0gvM1tm5OwZBaH1++aJj4JakACgwHZoRV08hmf6jGHVCoVStCOCe0TUT9enCMPs+Y+BFuoDWVlOLDi8=
artemis-test4.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHyKKZgX8bZ+k7N/B42LhBvJG2FcNhPL11q2L9FYDV/N2DAMHnBaxoruw+NdIaG0b/rfseUJKXPQiY6TMr0kOrk=
artemis-test4.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE9lVNwikkOcJb/7BdV200KcEtpisvhkOHMcKZeF3Tvb
- environment: artemis-test5.artemis.cit.tum.de
label-identifier: artemis-test5
url: https://artemis-test5.artemis.cit.tum.de
user: deployment
hosts: artemis-test5.artemis.cit.tum.de
folder: /opt/artemis
host_keys: |
artemis-test5.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD0NyNrw8dlJ99iGRSQ5IemSBpJyruNjFFFquiv8wsVRsBL6XPNySmZm0XWh8MjLxlL7DH3rUxXupaAnH6kQAAzt9gbWS4E+k21sfoKU0muf9rE1e7rUjnKgOm70b+6kpc7AS8HBAmzS2GuDzufPiyPYlUjozLhb2nAN685lT2v/Ofoe8tdWsR7AkB9pJE5P4NhAS/a4JujpyhO186F+SyT9k4X8FlfMi40qdBm1eIkg+eljVfbaIn0pKdoy/n8s0ODWu7vZpzNQxZb7qm5ROUjTqObSqsUA8oQv0JuWf4oudVLg3gxV1fEmEdAaWFt6W2mkiFaLeYTrhdtwD627WCyUPaSGe8yy8itEPsw2edfKZqb7s0+H6SlgvqR4rtKkbXs5gMG3Q2Ezj1C4SYrR/ME6oy6xt0zQEG7hiKIl2ArFZA6xRnhnqck8sTr+6oqRdNbKeErYroOYwKquNfuLHv1Fy2OpefMI+tjWSIFhDYDW2Y9d/ySPETyhHmZrn40Bk8=
artemis-test5.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBImSPJjIhJGsbUABhZfjM5vbc0UVC7JTDS1xwdIdJfAIEMo101EIS98C340VtiU4f6G2z59zpRB1Udptv1cxbPI=
artemis-test5.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHonMyIKiEHw7miwe5PJMDvWO/PwTpQpFYsvi2DUXYrO
- environment: artemis-test6.artemis.cit.tum.de
label-identifier: artemis-test6
url: https://artemis-test6.artemis.cit.tum.de
user: deployment
hosts: artemis-test6.artemis.cit.tum.de
folder: /opt/artemis
host_keys: |
artemis-test6.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKF/XYwHLiJ8JzYgcjxC9xRFrZqkLZz1sXa2PzJPTVzf+Ms58Emcor1/9Th+HgFtksEN2rsgPJackGBdigoDJn2n9ALzioWjIjdp4aH2Vl7wl91+ms2EWsAp1ZzywCFDYTQwqhmfztyS+SgKUrBGXJ+BB9rl115/0bt0wRCVhlI/QOWBp2renogzt/39BHEVNUp1dLeAReQmDjkiPZGyShkEVi1pODpIYoQ9KPcBlbT3/T5G3WaQDWZyt7J7vZa+nEI7rMRYcNF9RyqMs96dHmivputjg9ESNX9tH+3YonwCKdt2jCoV76VD31S3F7uK2pz5L7GdakM9n3CiT7K7msg7zFAPrxFoV3POpqWMc3NxEB7ZufQCL/VJ5mTZmj6jSUIRXsOdzZpgb6ZdqXd4cdWX56VY1YZwnXk9rxwxPDLyl3ugspvW9pmAJuk0/kltSq7j8w5toiclKgUte2CwrqOFdoj05m+1C1pUwCoeKxuV0ugHOS/M1fM64wikj9+cU=
artemis-test6.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBI5x3Yh7ecWwh+oitXTMwRnjyVRwlikkIqvmpYb4TF6rgSxBAxfkiWHiEyTWS7eBtdhp/v0FmhJV9dsehZSxZYQ=
artemis-test6.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMZdVOmY8K39PId1WPGMZaQwJvtDbGqJTdJX26YtDXgI
#- environment: artemis-test7.artemis.cit.tum.de
# label-identifier: artemis-test7
# url: https://artemis-test7.artemis.cit.tum.de
# user: deployment
# hosts: artemis-test7.artemis.cit.tum.de
# folder: /opt/artemis
# host_keys: |
# artemis-test7.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDPBbRDLfjS+OBEv+qRPyAqZGB4VzXporexFM1xzBRq6S+q5SSuik9uXJ+ZJE3m4jrXmU0S+41dRhPIVhjtzqQgRkFe4zBjbbinQJhVlb6u8PQp35+pgDFzMswELj3wv3FWeJSkCNivhyTe7R5ZF3KrzyuEzlgMmmuqogyaNwJeGapaCDxYIMKb6HokKVlwl2RVxPeT7wRLIwPF5bujCA3ZUGDPvVNJT2h0nX0u1vpAYIDK1+5G7Sod7OLhRO0C1T0WBF5bPRAZfFLP1eZMCeUjIY9Xsc+0TwRSBGDy1DA+hmrzD83BS2Juy2nEnSG3oC8J0DOfJ0hreTm/0EA4F1y5oz9x0qgnmVqtz/+R16OLCo8mEOmBSwVLeeQJKy75/NRMxoeQ+jl8GEvO8gwfgxbYwBg6nHQzAgslCTMxBCIWvufRLK7n9IAc0zQHDJEcn6o9dN4RvUkC8DnlUqW6C2RVfjqr1qiwa3pS5wDjLqD9ctzZzxwXK7tYyZIqKOsaj7k=
# artemis-test7.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOVPCPO7KIjhJs8ISnVLjyDyKIid42AIBylpyp6PIKCVwLM8GNVbdQtZEkzpLnR4tIXdf7fJvg9OyIu36Lf21po=
# artemis-test7.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMCmfbFQB7wbdaocZlWn45BYn8CaMfFHKuymHcLNq+JA
#- environment: artemis-test8.artemis.cit.tum.de
# label-identifier: artemis-test8
# url: https://artemis-test8.artemis.cit.tum.de
# user: deployment
# hosts: artemis-test8.artemis.cit.tum.de
# folder: /opt/artemis
# host_keys: |
# artemis-test8.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAioy2yTY0p/deKM6j7gMJA4tj7NadooMcPjkMkIHCFhVSsUPlhvBC1KzBm/JyfiXN/3kFZE9bZXnYn8aor2j4eiPXGEl3H070bTVPYCBuz3KHD/1zKpo/j317bacYSZivDb9HQmaGKBezDlx4R7+lZoAloozqXOfQU2AVOLD14bn75Xfxe+uB8gjNy0bACgolleKOHDTMMkLPc2O6i2X6yOa8c/kgbGzXZXEq9/rB81ggw8TBcf1FXaCgSlQMjoO69rbNBliMtybMnsdMZxan79xBT35LvlQtRezCGzT5U9NNaPluxkWBMgGCfIaj6CG8tliw6IQY0oKkpVEdsMZkltEzbgZ39Fn/telz0G8RL/GDC/1ew0b0dfE0IknExp7XzFrVokrmPcfF5D11s+F8ZeIYdyOUyLP9gEgscethj9MNTpVwoeiCvMyzOvypMF8DHxKxs73cqJ5W/vRacMepSPwv/KJCT7geX8KjO4ABbQG7GToiZ6wQYsnvTjtcWPs=
# artemis-test8.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGxtzUJPdHMAIfaL4Dr8OLMySCNInARsqnNN3e0JqHG/Y6xCVDVF9ZTOGUqMO9woMhsyTU6EOo6KaVfIVrw7SEA=
# artemis-test8.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFN6fu1oNKX3xFE1pe6Ichl5XJ/eTYhihywVvkH0mWRF
#- environment: artemis-test9.artemis.cit.tum.de
# label-identifier: artemis-test9
# url: https://artemis-test9.artemis.cit.tum.de
# user: deployment
# hosts: artemis-test9.artemis.cit.tum.de
# folder: /opt/artemis
# host_keys: |
# artemis-test9.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDRDisk0MgHoxymMGadsBitagXKn0DGhlg9khTHyel1CjQeNNc+d/sf8JHabodmMsZo4UKlKnVHDL48mzJWuTiacB0YvWfYYM+WKGZ3Wyc5INr4hK4Yj632UMEqBdLZqF3SJA2jPQk2u1rO416TeYJfR7pJwM694HmtuFifqmMaugV7evug195KckL+mxwxghjkRLtaY0AB5l0f0S5obVWTkKNaNaSKRidJfUyv6kZkZn2zZACWqkCudsEAjT6ZFXWhjiQqglmHZwlX6pLjsI6kL+C6xd4S/yB4okh3Rb7RVWxbT/9YzOAWJzRu1+IGf1/5UeFUEqKL1B8TJ0yZA1xZAXtvmYecK+iBibmeTXBNN/TBsTjPrArfUPnWN3/C8nf0lMyce/iPbyYMmu1oiHo3NdLXGsHpk2+oLAWjY7edcF/WyXOp0ax4OCIZ/lMsbA8euNewEahfDGFyRXzj694uwog8zpMtANb4+Lxo26N8hgSBZGsb22vLCHMerS5dfCU=
# artemis-test9.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBG3531IQdJVxkckhWGahHh4sb5REa3g+0UYMxGOKExj0Q/KxKFcfsu0rJ0vN4zKEfuZRHJouNcLQVVJfSDxqZF8=
# artemis-test9.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDbS/SXTRdYBE/qVjRHNMPXXMegsjBZrnuK6oAQJJstZ
#- environment: artemis-test10.artemis.cit.tum.de
# label-identifier: artemis-test10
# url: https://artemis-test10.artemis.cit.tum.de
# user: deployment
# hosts: artemis-test10.artemis.cit.tum.de
# folder: /opt/artemis
# host_keys: |
# artemis-test10.artemis.cit.tum.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC82ixfnlVeM94VjifcoGftJraCV71TMBD6/1lGEAvOAEkUckZCWjASRuyvzNvgJAeUYUe93oUfQnEdWRYrtvbWHtO/Oe0fZN0VQJorKnpFyuPOC363Z25Rc1PUAFX5lwlKBfeZkTvg1PVNE9o+yVLmeApRPLjUsF1aNrInbXXgzF4L2GgMgQvr6DW5WQQkwIrjJn4XlZV4nj6lheip+a194yD/4A05UJ/iHIEodzu5+UWVLn2HKZAbWO1VhhU75x5iuTtPASlbbsbq/3cDwSLrAMkI2Vyu4mXRNd4B/L6Js8ilwRe1iIaqnKeNswwfg/7TkCjCU+4sfdHnNc2iHx0vOayw/0pKEtn0L8SpJgBr5ncdIavRNsCZ1caRv44Ino2WWxq/sFFb4Wh2iXYqEbMhEKuBGqryzJF9veh0UTyOQXyuJBSJu4pZ/9YqG6F21girq2RFSWo+roZsnq+8LEkti4dGW22+yFvDgs3sqvTxgSVWIlQZt7CldVTvPyL/0+M=
# artemis-test10.artemis.cit.tum.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCICiCLtljuYwnBxGKurZjMuDsYFfSJ/5UD8gaDa1+CWPqmM4cFTniw+ORglDpaySlusPbXwll+K0JPkIm8E6+Y=
# artemis-test10.artemis.cit.tum.de ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAF8QXj0d2na/rBaVTIXfGu3HgtFppoE04Oj1Od2O3kD
outputs:
#TS1: ${{ steps.filter.outputs.artemis-test1 || '' }}
#TS2: ${{ steps.filter.outputs.artemis-test2 || '' }}
#TS3: ${{ steps.filter.outputs.artemis-test3 || '' }}
TS4: ${{ steps.filter.outputs.artemis-test4 || '' }}
TS5: ${{ steps.filter.outputs.artemis-test5 || '' }}
TS6: ${{ steps.filter.outputs.artemis-test6 || '' }}
#TS7: ${{ steps.filter.outputs.artemis-test7 || '' }}
#TS8: ${{ steps.filter.outputs.artemis-test8 || '' }}
#TS9: ${{ steps.filter.outputs.artemis-test9 || '' }}
#TS10: ${{ steps.filter.outputs.artemis-test10 || '' }}
steps:
- run: |
echo "$DEPLOY_LABEL"
echo '${{ contains(fromJSON(needs.get-labels.outputs.labels), format('deploy:{0}', matrix.label-identifier)) }}'
- id: filter
env:
MATRIX_JSON: ${{ toJSON(matrix) }}
if: ${{ contains(fromJSON(needs.get-labels.outputs.labels), format('deploy:{0}', matrix.label-identifier)) }}
run: |
MATRIX_JSON=${MATRIX_JSON//$'\n'/}
echo "${{ matrix.label-identifier }}=$MATRIX_JSON" >> $GITHUB_OUTPUT
# Process the output of the filter step to create a valid matrix for the deploy step
process-matrix:
needs: [ filter-matrix ]
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.process.outputs.matrix }}
steps:
- id: process
env:
MATRIX_JSON: ${{ toJSON(needs.filter-matrix.outputs.*) }}
run: |
MATRIX_JSON=${MATRIX_JSON//$'\n'/}
MATRIX_JSON=${MATRIX_JSON//$'"{'/'{'}
MATRIX_JSON=${MATRIX_JSON//$'}"'/'}'}
MATRIX_JSON=${MATRIX_JSON//$'\\"'/'"'}
echo "$MATRIX_JSON"
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
# Deploy to the test servers
deploy:
needs: [ process-matrix ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.process-matrix.outputs.matrix) }}
environment:
name: ${{ matrix.environment }}
url: ${{ matrix.url }}
env:
DEPLOYMENT_USER: ${{ matrix.user }}
DEPLOYMENT_HOSTS: ${{ matrix.hosts }}
DEPLOYMENT_FOLDER: ${{ matrix.folder }}
DEPLOYMENT_HOST_PUBLIC_KEYS: ${{ matrix.host_keys }}
GATEWAY_USER: "jump"
GATEWAY_HOST: "gateway.artemis.in.tum.de:2010"
GATEWAY_HOST_PUBLIC_KEY: "[gateway.artemis.in.tum.de]:2010 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtTLiKRILjKZ+Qg4ReWKsG7mLDXkzHfeY5nalSQUNQ4"
steps:
- uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: |
deploy:${{ matrix.label-identifier }}
- name: Check "lock:${{ matrix.environment }}" label
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const opts = github.rest.issues.listForRepo.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['lock:${{ matrix.label-identifier }}']
})
const issues = await github.paginate(opts)
if (issues.length == 1 && (!context.issue || issues[0].number != context.issue.number)) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### ❌ Unable to deploy to test servers ❌\nTestserver "${{ matrix.environment }}" is already in use by PR #${issues[0].number}.`
})
core.setFailed(`Testserver "${{ matrix.environment }}" is already in use by PR #${issues[0].number}.`);
} else if (issues.length > 1) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '### ❌ Unable to deploy to test servers ❌\nTestserver "${{ matrix.environment }}" is already in use by multiple PRs. Check PRs with label "lock:${{ matrix.label-identifier }}"!'
})
core.setFailed('Testserver "${{ matrix.environment }}" is already in use by multiple PRs. Check PRs with label "lock:${{ matrix.label-identifier }}"!');
} else if (context.issue && context.issue.number) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['lock:${{ matrix.label-identifier }}']
})
}
- name: Compute Tag
uses: actions/github-script@v6
id: compute-tag
with:
result-encoding: string
script: |
if (context.eventName === "pull_request") {
return "pr-" + context.issue.number;
}
if (context.eventName === "release") {
return "latest";
}
if (context.eventName === "push") {
if (context.ref.startsWith("refs/tags/")) {
return context.ref.slice(10);
}
if (context.ref === "refs/heads/develop") {
return "develop";
}
}
return "FALSE";
# Download artemis-server-cli from GH without cloning the Repo
- name: Fetch Artemis CLI
run: |
wget ${{ env.RAW_URL }}/artemis-server-cli
chmod +x artemis-server-cli
# Configure SSH Key
- name: Setup SSH Keys and known_hosts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
GATEWAY_SSH_KEY: "${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}"
DEPLOYMENT_SSH_KEY: "${{ secrets.DEPLOYMENT_SSH_KEY }}"
run: |
mkdir -p ~/.ssh
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< $GATEWAY_SSH_KEY
ssh-add - <<< $DEPLOYMENT_SSH_KEY
cat - <<< $GATEWAY_HOST_PUBLIC_KEY >> ~/.ssh/known_hosts
cat - <<< $(sed 's/\\n/\n/g' <<< "$DEPLOYMENT_HOST_PUBLIC_KEYS") >> ~/.ssh/known_hosts
- name: Deploy Artemis with Docker
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
TAG: ${{ steps.compute-tag.outputs.result }}
run: |
for host in $DEPLOYMENT_HOSTS; do
./artemis-server-cli docker-deploy "$DEPLOYMENT_USER@$host" -g "$GATEWAY_USER@$GATEWAY_HOST" -t $TAG -b $GITHUB_HEAD_REF -d $DEPLOYMENT_FOLDER -y
sleep 20
done
# Check that the build job has run successfully before deploying
add-error-label:
needs: [ check-build-status, filter-matrix, process-matrix, deploy ]
runs-on: ubuntu-latest
if: ${{ failure() }}
steps:
- name: Add error label
uses: actions-ecosystem/action-add-labels@v1
with:
labels: deployment-error