This repository has been archived by the owner on Aug 4, 2024. It is now read-only.
forked from workadventure/workadventure
-
Notifications
You must be signed in to change notification settings - Fork 0
972 lines (870 loc) · 42.4 KB
/
build-test-and-deploy.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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
name: Build, push, test and deploy Docker image
on:
push:
branches: [master, develop]
release:
types: [created]
pull_request:
types: [labeled, synchronize, opened, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-play:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: rlespinasse/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thecodingmachine/workadventure-play
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
context: .
file: play/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-play:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-play:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-play:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
secrets: |
"SENTRY_URL=${{ secrets.SENTRY_URL }}"
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
"SENTRY_ORG=${{ secrets.SENTRY_ORG }}"
"SENTRY_PROJECT=play"
"SENTRY_ENVIRONMENT=${{ github.event_name == 'release' && 'production' || env.GITHUB_REF_NAME == 'master' && 'staging' || 'testing' }}"
"SENTRY_RELEASE=${{ github.event_name == 'release' && env.GITHUB_REF_NAME || format('{0}@{1}', env.GITHUB_REF_NAME, env.GITHUB_SHA) }}"
- name: Build test image
uses: docker/build-push-action@v3
with:
context: .
file: play/Dockerfile
platforms: linux/amd64
push: false
tags: thecodingmachine/workadventure-play:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-play:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-play:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/play.tar
- name: Load image (for sentry)
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
run: docker load --input /tmp/play.tar
- name: Sentry push source maps
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
continue-on-error: true
env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: pusher
SENTRY_ENVIRONMENT: ${{ github.event_name == 'release' && 'production' || env.GITHUB_REF_NAME == 'master' && 'staging' || 'testing' }}
SENTRY_RELEASE: ${{ github.event_name == 'release' && env.GITHUB_REF_NAME || format('{0}@{1}', env.GITHUB_REF_NAME, env.GITHUB_SHA) }}
run: |
docker run --rm \
--user 0 \
-e SENTRY_URL \
-e SENTRY_AUTH_TOKEN \
-e SENTRY_ORG \
-e SENTRY_PROJECT \
-e SENTRY_RELEASE \
-e SENTRY_ENVIRONMENT \
thecodingmachine/workadventure-play:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} \
/bin/sh -c 'npm install --dev && npm run push-sentry-sourcemaps'
- name: Zip image
run: gzip play.tar
working-directory: /tmp
- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: play
path: /tmp/play.tar.gz
build-chat:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: rlespinasse/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thecodingmachine/workadventure-chat
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
context: .
file: chat/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-chat:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
secrets: |
"SENTRY_URL=${{ secrets.SENTRY_URL }}"
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
"SENTRY_ORG=${{ secrets.SENTRY_ORG }}"
"SENTRY_PROJECT=chat"
"SENTRY_ENVIRONMENT=${{ github.event_name == 'release' && 'production' || env.GITHUB_REF_NAME == 'master' && 'staging' || 'testing' }}"
"SENTRY_RELEASE=${{ github.event_name == 'release' && env.GITHUB_REF_NAME || format('{0}@{1}', env.GITHUB_REF_NAME, env.GITHUB_SHA) }}"
- name: Build test image
uses: docker/build-push-action@v3
with:
context: .
file: chat/Dockerfile
platforms: linux/amd64
push: false
tags: thecodingmachine/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-chat:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/chat.tar
- name: Zip image
run: gzip chat.tar
working-directory: /tmp
- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: chat
path: /tmp/chat.tar.gz
build-back:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: rlespinasse/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thecodingmachine/workadventure-back
- name: Replace version string
run: |
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
sed -i "s/dev/${GITHUB_REF_NAME}/" back/src/Services/version.ts
fi
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
context: .
file: back/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-back:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
- name: Build test image
uses: docker/build-push-action@v3
with:
context: .
file: back/Dockerfile
platforms: linux/amd64
push: false
tags: thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-back:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/back.tar
- name: Load image (for sentry)
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
run: docker load --input /tmp/back.tar
- name: Sentry push source maps
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: back
SENTRY_ENVIRONMENT: ${{ github.event_name == 'release' && 'production' || env.GITHUB_REF_NAME == 'master' && 'staging' || 'testing' }}
SENTRY_RELEASE: ${{ github.event_name == 'release' && env.GITHUB_REF_NAME || format('{0}@{1}', env.GITHUB_REF_NAME, env.GITHUB_SHA) }}
run: |
docker run --rm \
--user 0 \
-e SENTRY_URL \
-e SENTRY_AUTH_TOKEN \
-e SENTRY_ORG \
-e SENTRY_PROJECT \
-e SENTRY_RELEASE \
-e SENTRY_ENVIRONMENT \
thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} \
/bin/sh -c 'npm install --dev && npm run push-sentry-sourcemaps'
- name: Zip image
run: gzip back.tar
working-directory: /tmp
- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: back
path: /tmp/back.tar.gz
build-uploader:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: rlespinasse/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thecodingmachine/workadventure-uploader
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
file: uploader/Dockerfile
push: true
tags: thecodingmachine/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-uploader:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
- name: Build test image
uses: docker/build-push-action@v3
with:
file: uploader/Dockerfile
push: false
tags: thecodingmachine/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-uploader:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/uploader.tar
- name: Zip image
run: gzip uploader.tar
working-directory: /tmp
- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: uploader
path: /tmp/uploader.tar.gz
build-maps:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: rlespinasse/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thecodingmachine/workadventure-maps
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
context: maps/
file: maps/Dockerfile
push: true
tags: thecodingmachine/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-maps:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
- name: Build test image
uses: docker/build-push-action@v3
with:
context: maps/
file: maps/Dockerfile
push: false
tags: thecodingmachine/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-maps:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/maps.tar
- name: Zip image
run: gzip maps.tar
working-directory: /tmp
- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: maps
path: /tmp/maps.tar.gz
build-map-storage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: rlespinasse/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thecodingmachine/workadventure-map-storage
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
context: .
file: map-storage/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-map-storage:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
- name: Build test image
uses: docker/build-push-action@v3
with:
context: .
file: map-storage/Dockerfile
platforms: linux/amd64
push: false
tags: thecodingmachine/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-map-storage:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/map-storage.tar
- name: Load image (for sentry)
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
run: docker load --input /tmp/map-storage.tar
- name: Sentry push source maps
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: map-storage
SENTRY_ENVIRONMENT: ${{ github.event_name == 'release' && 'production' || env.GITHUB_REF_NAME == 'master' && 'staging' || 'testing' }}
SENTRY_RELEASE: ${{ github.event_name == 'release' && env.GITHUB_REF_NAME || format('{0}@{1}', env.GITHUB_REF_NAME, env.GITHUB_SHA) }}
run: |
docker run --rm \
--user 0 \
-e SENTRY_URL \
-e SENTRY_AUTH_TOKEN \
-e SENTRY_ORG \
-e SENTRY_PROJECT \
-e SENTRY_RELEASE \
-e SENTRY_ENVIRONMENT \
thecodingmachine/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} \
/bin/sh -c 'cd /usr/src && npm ci -w map-storage && cd /usr/src/map-storage && npm run push-sentry-sourcemaps'
- name: Zip image
run: gzip map-storage.tar
working-directory: /tmp
- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: map-storage
path: /tmp/map-storage.tar.gz
build-ejabberd:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: rlespinasse/[email protected]
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thecodingmachine/workadventure-ejabberd
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
context: xmpp/
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-ejabberd:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-ejabberd:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-ejabberd:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
- name: Build test image
uses: docker/build-push-action@v3
with:
context: xmpp/
platforms: linux/amd64
push: false
tags: thecodingmachine/workadventure-ejabberd:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: |
type=registry,ref=thecodingmachine/workadventure-ejabberd:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
type=registry,ref=thecodingmachine/workadventure-ejabberd:develop
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/ejabberd.tar
- name: Zip image
run: gzip ejabberd.tar
working-directory: /tmp
- name: Upload image as artifact
uses: actions/upload-artifact@v3
with:
name: ejabberd
path: /tmp/ejabberd.tar.gz
end-to-end-tests:
name: "End to end tests with ${{ matrix.browser }} (${{ matrix.shard }}/${{ matrix.nbShards }})"
strategy:
fail-fast: false
matrix:
include:
- browser: chromium
shard: 1
nbShards: 3
renderer: auto
- browser: chromium
shard: 2
nbShards: 3
renderer: auto
- browser: chromium
shard: 3
nbShards: 3
renderer: auto
- browser: firefox
shard: 1
nbShards: 3
renderer: auto
- browser: firefox
shard: 2
nbShards: 3
renderer: auto
- browser: firefox
shard: 3
nbShards: 3
renderer: auto
- browser: webkit
shard: 1
nbShards: 5
renderer: headless
- browser: webkit
shard: 2
nbShards: 5
renderer: headless
- browser: webkit
shard: 3
nbShards: 5
renderer: headless
- browser: webkit
shard: 4
nbShards: 5
renderer: headless
- browser: webkit
shard: 5
nbShards: 5
renderer: headless
renderer: auto
- browser: mobilechrome
shard: 1
nbShards: 1
renderer: auto
needs:
- build-play
- build-chat
- build-back
- build-maps
- build-uploader
- build-map-storage
- build-ejabberd
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
working-directory: tests
- name: Install Playwright
run: npx playwright install --with-deps ${{ matrix.browser }}
working-directory: tests
- name: 'Setup .env file'
run: cp .env.template .env
- uses: rlespinasse/[email protected]
- name: Display pulled version
run: echo "Pulling images with tag ${DOCKER_TAG}"
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- name: "Install Room Api client dependencies"
run: npm ci
working-directory: "libs/room-api-clients/room-api-client-js"
- name: "Build Room Api client proto files"
run: npm run ts-proto
working-directory: "libs/room-api-clients/room-api-client-js"
- name: Fill .env file
run: |
sed -i "s/ROOM_API_SECRET_KEY=/ROOM_API_SECRET_KEY=MYAWESOMEKEY/g" .env
sed -i "s/JITSI_DOMAIN=/JITSI_DOMAIN=coremeet.workadventu.re/g" .env
sed -i "s/JITSI_MUC_DOMAIN=/JITSI_MUC_DOMAIN=muc.prosody.workadventu.re/g" .env
sed -i "s/JITSI_XMPP_DOMAIN=/JITSI_XMPP_DOMAIN=prosody.workadventu.re/g" .env
sed -i "s/KLAXOON_ENABLED=false/KLAXOON_ENABLED=true/g" .env
sed -i "s/KLAXOON_CLIENT_ID=/KLAXOON_CLIENT_ID=${{ env.KLAXOON_CLIENT_ID }}/g" .env
env:
KLAXOON_CLIENT_ID: ${{ secrets.KLAXOON_CLIENT_ID }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: play
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: chat
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: back
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: maps
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: map-storage
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: uploader
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ejabberd
path: /tmp
- name: Load image
run: |
docker load --input /tmp/play.tar.gz
docker load --input /tmp/chat.tar.gz
docker load --input /tmp/back.tar.gz
docker load --input /tmp/maps.tar.gz
docker load --input /tmp/map-storage.tar.gz
docker load --input /tmp/uploader.tar.gz
docker load --input /tmp/ejabberd.tar.gz
docker image ls -a
- name: Start WorkAdventure
run: |
docker-compose -f docker-compose.yaml -f docker-compose-oidc.yaml -f docker-compose.e2e.yml pull
docker-compose -f docker-compose.yaml -f docker-compose-oidc.yaml -f docker-compose.e2e.yml up -d
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- name: Upload test-map
run: sleep 30 && npm run upload-test-map
working-directory: map-storage
- name: Run Playwright tests
run: npm run test-prod-like -- --project=${{ matrix.browser }} --shard=${{ matrix.shard }}/${{ matrix.nbShards }}
working-directory: tests
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
RENDERER_MODE: ${{ matrix.renderer }}
- name: Display docker-compose logs on failure
run: docker-compose -f docker-compose.yaml -f docker-compose-oidc.yaml -f docker-compose.e2e.yml logs
if: failure()
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- name: Display containers state
run: docker-compose -f docker-compose.yaml -f docker-compose-oidc.yaml -f docker-compose.e2e.yml ps
if: failure()
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- name: Side-load docker-compose logs in the playwright report
run: docker-compose -f docker-compose.yaml -f docker-compose-oidc.yaml -f docker-compose.e2e.yml logs > tests/playwright-report/docker-compose.log
if: failure()
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- uses: actions/upload-artifact@v2
if: always()
with:
name: playwright-report-${{ matrix.browser }}-${{ matrix.shard }}-${{ matrix.nbShards }}
path: tests/playwright-report/
retention-days: 30
prod-single-domain-deploy-tests:
name: "Test production docker-compose (${{ matrix.shard }}/${{ matrix.nbShards }})"
strategy:
fail-fast: false
matrix:
include:
- shard: 1
nbShards: 2
- shard: 2
nbShards: 2
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
needs:
- build-play
- build-chat
- build-back
- build-maps
- build-uploader
- build-map-storage
- build-ejabberd
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
working-directory: tests
- name: Install Playwright
run: npx playwright install --with-deps chromium
working-directory: tests
- name: 'Setup .env file'
run: cp .env.prod.template .env
working-directory: contrib/docker
- uses: rlespinasse/[email protected]
- name: "Install Room Api client dependencies"
run: npm ci
working-directory: "libs/room-api-clients/room-api-client-js"
- name: "Build Room Api client proto files"
run: npm run ts-proto
working-directory: "libs/room-api-clients/room-api-client-js"
- name: Fill .env file
run: |
sed -i "s/SECRET_KEY=/SECRET_KEY=someSecret/g" .env
sed -i "s/VERSION=master/VERSION=${DOCKER_TAG}/g" .env
sed -i "s/DOMAIN=workadventure.localhost/DOMAIN=play.workadventure.localhost/g" .env
sed -i "s/MAP_STORAGE_AUTHENTICATION_USER=/MAP_STORAGE_AUTHENTICATION_USER=john.doe/g" .env
sed -i "s/MAP_STORAGE_AUTHENTICATION_PASSWORD=/MAP_STORAGE_AUTHENTICATION_PASSWORD=password/g" .env
sed -i "s/ADMIN_API_TOKEN=/ADMIN_API_TOKEN=123/g" .env
sed -i "s/ROOM_API_SECRET_KEY=/ROOM_API_SECRET_KEY=MYAWESOMEKEY/g" .env
sed -i "s/JITSI_DOMAIN=/JITSI_DOMAIN=coremeet.workadventu.re/g" .env
sed -i "s/JITSI_MUC_DOMAIN=/JITSI_MUC_DOMAIN=muc.prosody.workadventu.re/g" .env
sed -i "s/JITSI_XMPP_DOMAIN=/JITSI_XMPP_DOMAIN=prosody.workadventu.re/g" .env
sed -i "s/FEATURE_FLAG_BROADCAST_AREAS=/FEATURE_FLAG_BROADCAST_AREAS=true/g" .env
sed -i "s/KLAXOON_ENABLED=false/KLAXOON_ENABLED=true/g" .env
sed -i "s/KLAXOON_CLIENT_ID=/KLAXOON_CLIENT_ID=${{ env.KLAXOON_CLIENT_ID }}/g" .env
echo "WOKA_SPEED=3" >> .env
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
KLAXOON_CLIENT_ID: ${{ secrets.KLAXOON_CLIENT_ID }}
working-directory: contrib/docker
- name: Start WorkAdventure
run: docker-compose -f docker-compose.prod.yaml -f tests/docker-compose.test-maps.yaml up -d
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
working-directory: contrib/docker
- name: Upload test-map
run: |
sed -i "s/http:/https:/g" tests/assets/maps/empty.wam
sleep 10
npm run upload-test-map-single-domain
working-directory: map-storage
- name: Run Playwright tests
# Run all tests, except the ones needing to restart Docker and the ones relying on an OIDC server
run: npm run test-single-domain-install -- --shard ${{ matrix.shard }}/${{ matrix.nbShards }}
working-directory: tests
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- name: Display docker-compose logs on failure
run: docker-compose -f docker-compose.prod.yaml -f tests/docker-compose.test-maps.yaml logs
if: failure()
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
working-directory: contrib/docker
- name: Display containers state
run: docker-compose -f docker-compose.prod.yaml -f tests/docker-compose.test-maps.yaml ps
if: failure()
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
working-directory: contrib/docker
- name: Side-load docker-compose logs in the playwright report
run: docker-compose -f docker-compose.prod.yaml -f tests/docker-compose.test-maps.yaml logs > ../../tests/playwright-report/docker-compose.log
if: failure()
env:
DOCKER_TAG: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
working-directory: contrib/docker
- uses: actions/upload-artifact@v2
if: always()
with:
name: playwright-report-single-domain-${{ matrix.shard }}-${{ matrix.nbShards }}
path: tests/playwright-report/
retention-days: 30
deeploy:
needs:
- build-play
- build-chat
- build-back
- build-maps
- build-uploader
- build-map-storage
- build-ejabberd
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
steps:
- name: Checkout
uses: actions/checkout@v2
# Create a slugified value of the branch
- uses: rlespinasse/[email protected]
- name: Set ADMIN_URL if "deploy-connect-to-admin" label is set
run: echo "ADMIN_API_URL=https://admin-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}.test.workadventu.re" >> $GITHUB_ENV
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-connect-to-admin')) || env.GITHUB_REF_SLUG == 'develop' }}
- name: Write certificate
run: echo "${CERTS_PRIVATE_KEY}" > secret.key && chmod 0600 secret.key
env:
CERTS_PRIVATE_KEY: ${{ secrets.CERTS_PRIVATE_KEY }}
- name: Download certificate
run: mkdir secrets && scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i secret.key [email protected]:./config/live/workadventu.re/* secrets/
- name: Create namespace
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with:
args: create namespace workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
continue-on-error: true
- name: Delete old certificates in namespace
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with:
args: -n workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} delete secret certificate-tls
continue-on-error: true
- name: Install certificates in namespace
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with:
args: -n workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} create secret tls certificate-tls --key="secrets/privkey.pem" --cert="secrets/fullchain.pem"
- name: Deploy with deeployer
uses: thecodingmachine/deeployer-action@master
env:
KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }}
ADMIN_API_TOKEN: ${{ secrets.ADMIN_API_TOKEN }}
ADMIN_SOCKETS_TOKEN: ${{ secrets.ADMIN_SOCKETS_TOKEN }}
JITSI_ISS: ${{ secrets.JITSI_ISS }}
JITSI_URL: ${{ secrets.JITSI_URL }}
SECRET_JITSI_KEY: ${{ secrets.SECRET_JITSI_KEY }}
TURN_STATIC_AUTH_SECRET: ${{ secrets.TURN_STATIC_AUTH_SECRET }}
DEPLOY_REF: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
POSTHOG_URL: ${{ secrets.POSTHOG_URL }}
EJABBERD_JWT_SECRET: ${{ secrets.EJABBERD_JWT_SECRET }}
ENABLE_REPORT_ISSUES_MENU: ${{ secrets.ENABLE_REPORT_ISSUES_MENU }}
REPORT_ISSUES_URL: ${{ secrets.REPORT_ISSUES_URL }}
LOGROCKET_ID: ${{ secrets.LOGROCKET_ID }}
KLAXOON_CLIENT_ID: ${{ secrets.KLAXOON_CLIENT_ID }}
GOOGLE_DRIVE_PICKER_CLIENT_ID: ${{ secrets.GOOGLE_DRIVE_PICKER_CLIENT_ID }}
GOOGLE_DRIVE_PICKER_APP_ID: ${{ secrets.GOOGLE_DRIVE_PICKER_APP_ID }}
with:
namespace: workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- name: Perform environment substitution in K8S files
run: envsubst < cd/map-storage-traefik-ingress-route.tmpl.yaml > cd/map-storage-traefik-ingress-route.yaml
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-connect-to-admin')) || env.GITHUB_REF_SLUG == 'develop' }}
env:
DEPLOY_REF: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
- name: Deploy custom K8S files
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with:
args: -n workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} apply -f cd/map-storage-traefik-ingress-route.yaml
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-connect-to-admin')) || env.GITHUB_REF_SLUG == 'develop' }}
- name: Upload demo maps in map-storage
run: rm -f tests/assets.zip && cd tests/assets && zip -r ../assets.zip * && curl -F 'file=@../assets.zip' https://map-storage-${DEPLOY_REF}.test.workadventu.re/upload --basic -u john.doe:password
env:
DEPLOY_REF: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
working-directory: map-storage
- name: Add a comment in PR
uses: unsplash/comment-on-pr@master
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Environment deployed at https://play-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re \nTests available at https://maps-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re/tests"
check_for_duplicate_msg: true