generated from digitalservicebund/java-application-template
-
Notifications
You must be signed in to change notification settings - Fork 9
856 lines (832 loc) · 35.6 KB
/
pipeline.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
name: Pipeline
on:
push:
branches: [ main ]
paths-ignore:
- '**/*.md'
pull_request:
branches: [ main ]
schedule:
- cron: "0 18 * * *" # Every day at 8pm
# Allow to run this workflow manually
workflow_dispatch:
env:
RUN_ID: ${{ github.run_id }}
CONTAINER_REGISTRY: ghcr.io
CONTAINER_IMAGE_NAME: ${{ github.repository }}
CONTAINER_IMAGE_VERSION: ${{ github.event.pull_request.head.sha || github.sha }} # Use PR head SHA if available
GH_PACKAGES_REPOSITORY_USER: ${{ secrets.GH_PACKAGES_REPOSITORY_USER }} # Secrets must not start with "GITHUB_".
GH_PACKAGES_REPOSITORY_TOKEN: ${{ secrets.GH_PACKAGES_REPOSITORY_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
REPORTS_REPOSITORY: digitalservicebund/ris-reports
jobs:
backend-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Gradle version
working-directory: ./backend
run: |
echo "GRADLE_VERSION=$(sed -n 's/.*gradle-\([0-9]*\(\.[0-9]*\)*\)-.*/\1/p' ./gradle/wrapper/gradle-wrapper.properties)" >> $GITHUB_ENV
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
with:
java-version: "21.0"
distribution: "temurin"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Run backend tests
working-directory: ./backend
run: ./gradlew build --profile -x integrationTest -x test
- name: Upload build performance report
uses: actions/upload-artifact@v4
with:
name: performance-report
path: backend/build/reports/profile/profile*.html
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
backend-checks:
uses: ./.github/workflows/backend-checks.yml
secrets: inherit
backend-build-image-and-scan:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Get Gradle version
working-directory: ./backend
run: |
echo "GRADLE_VERSION=$(sed -n 's/.*gradle-\([0-9]*\(\.[0-9]*\)*\)-.*/\1/p' ./gradle/wrapper/gradle-wrapper.properties)" >> $GITHUB_ENV
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
with:
java-version: "21.0"
distribution: "temurin"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Build backend image
working-directory: ./backend
run: ./gradlew bootBuildImage
- name: Run Trivy vulnerability image scanner
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0
env:
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
with:
image-ref: ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}:${{ env.CONTAINER_IMAGE_VERSION }}
format: "sarif"
output: "trivy-results.sarif"
github-pat: ${{ secrets.GITHUB_TOKEN }}
- name: Check trivy results
run: |
if grep -qE 'HIGH|CRITICAL' trivy-results.sarif; then
echo "Vulnerabilities found"
exit 1
else
echo "No significant vulnerabilities found"
exit 0
fi
# Todo: Remove this step
- name: Upload Trivy scan results
uses: actions/upload-artifact@v4
with:
name: "trivy-results-backend.sarif"
path: "trivy-results.sarif"
if-no-files-found: error
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: ${{ always() && github.ref == 'refs/heads/main' }} # Bypass non-zero exit code..
with:
sarif_file: "trivy-results.sarif"
- name: Generate cosign vulnerability scan record
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0
env:
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
with:
image-ref: ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}:${{ env.CONTAINER_IMAGE_VERSION }}
format: "cosign-vuln"
output: "vuln-backend.json"
- name: Upload cosign vulnerability scan record
uses: actions/upload-artifact@v4
with:
name: "vuln-backend.json"
path: "vuln-backend.json"
if-no-files-found: error
- name: Save image
run: |
mkdir /tmp/images
docker save -o /tmp/images/backend-image.tar ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}:${{ env.CONTAINER_IMAGE_VERSION }}
- uses: actions/cache@v4
with:
path: /tmp/images
key: docker-images-cache-${{ env.RUN_ID }}
restore-keys: docker-images-cache-${{ env.RUN_ID }}
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
frontend-checks:
uses: ./.github/workflows/frontend-checks.yml
secrets: inherit
audit-licenses-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
with:
java-version: "21.0"
distribution: "temurin"
cache: gradle
- name: Grant execute permission for gradlew
working-directory: ./backend
run: chmod +x gradlew
- name: Run license scanner
working-directory: ./backend
run: ./gradlew checkLicense
- name: Upload licence report
uses: actions/upload-artifact@v4
with:
name: licence-reports-backend
retention-days: 3
path: backend/build/reports/dependency-license/backend-licence-report.csv
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
audit-licenses-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ./frontend/package.json
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Run license scanner
run: npm run audit:licences
working-directory: ./frontend
- name: Upload licence report
uses: actions/upload-artifact@v4
with:
name: licence-reports-frontend
retention-days: 3
path: frontend/frontend-licence-report.csv
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
frontend-build-image-and-scan:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Build frontend image
run: docker build --file frontend/Dockerfile.prod --tag ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}/frontend:${{ env.CONTAINER_IMAGE_VERSION }} ./frontend
- name: Run Trivy vulnerability image scanner
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0
env:
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
with:
image-ref: ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}/frontend:${{ env.CONTAINER_IMAGE_VERSION }}
format: "sarif"
output: "trivy-results.sarif"
- name: Check trivy results
run: |
if grep -qE 'HIGH|CRITICAL' trivy-results.sarif; then
echo "Vulnerabilities found"
exit 1
else
echo "No significant vulnerabilities found"
exit 0
fi
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: ${{ always() && github.ref == 'refs/heads/main' }} # Bypass non-zero exit code..
with:
sarif_file: "trivy-results.sarif"
- name: Run Trivy vulnerability file scanner
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0
env:
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
with:
scan-type: "fs"
scan-ref: "./frontend"
skip-dirs: "node_modules" # See https://github.com/aquasecurity/trivy/issues/1283
format: "sarif"
output: "trivy-results.sarif"
- name: Check trivy results
run: |
if grep -qE 'HIGH|CRITICAL' trivy-results.sarif; then
echo "Vulnerabilities found"
exit 1
else
echo "No significant vulnerabilities found"
exit 0
fi
- name: Upload Trivy file scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: ${{ always() && github.ref == 'refs/heads/main' }} # Bypass non-zero exit code..
with:
sarif_file: "trivy-results.sarif"
category: trivy-fs-scan
- name: Generate cosign vulnerability scan record
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0
env:
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
with:
image-ref: ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}/frontend:${{ env.CONTAINER_IMAGE_VERSION }}
format: "cosign-vuln"
output: "vuln-frontend.json"
- name: Upload cosign vulnerability scan record
uses: actions/upload-artifact@v4
with:
name: "vuln-frontend.json"
path: "vuln-frontend.json"
if-no-files-found: error
- name: Save image
run: |
mkdir /tmp/images
docker save -o /tmp/images/frontend-image.tar ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}/frontend:${{ env.CONTAINER_IMAGE_VERSION }}
- uses: actions/cache@v4
with:
path: /tmp/images
key: docker-frontend-images-cache-${{ env.RUN_ID }}
restore-keys: docker-frontend-images-cache-${{ env.RUN_ID }}
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
push-backend-image-to-registry:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'dev-env') || contains(github.event.labeled.labels.*.name, 'dev-env') }}
needs:
- backend-build
- backend-checks
- backend-build-image-and-scan
- audit-licenses-backend
permissions:
contents: read
id-token: write # This is used to complete the identity challenge with sigstore/fulcio..
packages: write
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/cache@v4
with:
path: /tmp/images
key: docker-images-cache-${{ env.RUN_ID }}
restore-keys: docker-images-cache-${{ env.RUN_ID }}
- name: load image
shell: bash
run: docker load -i /tmp/images/backend-image.tar
- name: Log into container registry
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: docker/login-action@7ca345011ac4304463197fac0e56eab1bc7e6af0
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish backend container image
run: docker push ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}:${{ env.CONTAINER_IMAGE_VERSION }}
- name: Install cosign
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: sigstore/cosign-installer@e11c0892438d2c0a48e49dee376e4883f10f2e59
- name: Sign the published Docker image
run: cosign sign --yes ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}:${{ env.CONTAINER_IMAGE_VERSION }}
- id: set-version
run: echo "version=$CONTAINER_IMAGE_VERSION" >> "$GITHUB_OUTPUT"
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
push-frontend-image-to-registry:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'dev-env') || contains(github.event.labeled.labels.*.name, 'dev-env') }}
needs:
- frontend-checks
- frontend-build-image-and-scan
- audit-licenses-frontend
permissions:
contents: read
id-token: write # This is used to complete the identity challenge with sigstore/fulcio..
packages: write
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/cache@v4
with:
path: /tmp/images
key: docker-frontend-images-cache-${{ env.RUN_ID }}
restore-keys: docker-images-cache-${{ env.RUN_ID }}
- name: load image
shell: bash
run: docker load -i /tmp/images/frontend-image.tar
- name: Log into container registry
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: docker/login-action@7ca345011ac4304463197fac0e56eab1bc7e6af0
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish backend container image
run: docker push ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}/frontend:${{ env.CONTAINER_IMAGE_VERSION }}
- name: Install cosign
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: sigstore/cosign-installer@e11c0892438d2c0a48e49dee376e4883f10f2e59
- name: Sign the published Docker image
run: cosign sign --yes ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}/frontend:${{ env.CONTAINER_IMAGE_VERSION }}
- id: set-version
run: echo "version=$CONTAINER_IMAGE_VERSION" >> "$GITHUB_OUTPUT"
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
deploy-staging:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
concurrency:
group: deploy-staging
cancel-in-progress: true
environment: staging
needs:
- push-frontend-image-to-registry
- push-backend-image-to-registry
permissions:
id-token: write # Enable OIDC for gitsign
steps:
- uses: chainguard-dev/actions/setup-gitsign@0c26ac0ebfc8e53f8c2debe657cc2c5f6fe26663
- name: Deploy new images
uses: digitalservicebund/argocd-deploy@4fac1bb67c92ed168f6d9b22f8779ce241a9e412 # v1.0.0
with:
environment: staging
version: ${{ needs.push-backend-image-to-registry.outputs.version }}
deploying_repo: ris-backend-service,ris-backend-service/frontend
infra_repo: neuris-infra
deploy_key: ${{ secrets.DEPLOY_KEY }}
app: ris-staging
argocd_pipeline_password: ${{ secrets.ARGOCD_PIPELINE_PASSWORD }}
argocd_server: ${{ secrets.ARGOCD_SERVER }}
argocd_sync_timeout: 300
- name: Track deploy
uses: digitalservicebund/track-deployment@5a2815e150e1268983aac5ca04c8c046ed1b614a # v1.0.0
with:
project: RIS
environment: staging
metrics_deployment_webhook_url: ${{ secrets.METRICS_DEPLOYMENT_WEBHOOK_URL }}
metrics_webhook_token: ${{ secrets.METRICS_WEBHOOK_TOKEN }}
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
prep-playwright-tests:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ./frontend/package.json
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Get Playwright version
working-directory: ./frontend
run: echo "PLAYWRIGHT_VERSION=$(jq -r '.packages["node_modules/@playwright/test"].version' package-lock.json)" >> $GITHUB_ENV
- name: Cache browser binaries
id: cache-browser-binaries
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Install browsers
if: steps.cache-browser-binaries.outputs.cache-hit != 'true'
run: |
npx --yes playwright install --with-deps chromium firefox
working-directory: ./frontend
e2e-tests:
if: ${{ github.ref == 'refs/heads/main' }}
concurrency:
group: deploy-staging
cancel-in-progress: true
needs: [ deploy-staging, prep-playwright-tests ]
# We do not include the matrix directly, so that the concurrency group does not apply to each matrix job individually
uses: ./.github/workflows/e2e_matrix.yml
secrets: inherit
query-performance-tests:
if: ${{ github.ref == 'refs/heads/main' }}
concurrency:
group: deploy-staging
cancel-in-progress: true
needs: [ e2e-tests, prep-playwright-tests ]
uses: ./.github/workflows/_playwright-test.yml
with:
subproject: "all"
browser: "queries" # uses the 'queries' project
mode: "queries"
runs: 1
workers: 1
secrets: inherit
generate-test-reports:
if: ${{ !cancelled() && github.ref == 'refs/heads/main' }}
needs: [ e2e-tests ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ./frontend/package.json
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Cache node_modules
uses: actions/cache@v4
id: node-modules-cache
with:
path: |
./frontend/node_modules
key: modules-${{ hashFiles('./frontend/package-lock.json') }}
- name: Install dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: |
npm ci
working-directory: ./frontend
- name: Download blob reports from artifacts
uses: actions/download-artifact@v4
with:
path: ./frontend/all-blob-reports
pattern: test-results-blob-*
- name: Prepare test reports for merge
working-directory: ./frontend/all-blob-reports
run: |
for DIR in test-results-blob-*; do
unzip -o "$DIR/test-report.zip" -d "$DIR"
rm "$DIR/test-report.zip"
ZIP_FILE="../$(basename "$DIR").zip"
(cd "$DIR" && zip -r "$ZIP_FILE" ./*.jsonl)
rm -rf "$DIR"
done
shell: bash
- name: Merge into html report
run: npx playwright merge-reports --reporter html ./all-blob-reports
working-directory: ./frontend
- name: Upload html report to artifacts
uses: actions/upload-artifact@v4
with:
name: html-test-report
path: ./frontend/playwright-report
check-latest-deploy-tag:
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- e2e-tests
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ steps.compare-tags.outputs.should_deploy }}
environment: production
steps:
- name: Checkout infra repository
uses: actions/checkout@v4
with:
repository: digitalservicebund/neuris-infra
ssh-key: ${{ secrets.DEPLOY_KEY }}
path: infra
- name: Checkout main repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: main
- name: compare image tags
id: compare-tags
run: |
set -x
CURRENT_TAG=${{ env.CONTAINER_IMAGE_VERSION }}
DEPLOYED_TAG=$(yq '.images[0] | .newTag' infra/manifests/overlays/production/kustomization.yaml)
cd main
if git merge-base --is-ancestor $CURRENT_TAG $DEPLOYED_TAG; then
echo "should_deploy=false" >> "$GITHUB_OUTPUT"
else
echo "should_deploy=true" >> "$GITHUB_OUTPUT"
fi
deploy-production:
runs-on: ubuntu-latest
if: |
github.ref == 'refs/heads/main' &&
needs.check-latest-deploy-tag.outputs.should_deploy == 'true'
concurrency: deploy-production
environment: production
needs:
- push-frontend-image-to-registry
- push-backend-image-to-registry
- e2e-tests
- check-latest-deploy-tag
- backend-checks
- frontend-checks
permissions:
id-token: write # Enable OIDC for gitsign
steps:
- uses: chainguard-dev/actions/setup-gitsign@0c26ac0ebfc8e53f8c2debe657cc2c5f6fe26663
- name: Deploy new images
uses: digitalservicebund/argocd-deploy@4fac1bb67c92ed168f6d9b22f8779ce241a9e412 # v1.0.0
with:
environment: production
version: ${{ needs.push-backend-image-to-registry.outputs.version }}
deploying_repo: ris-backend-service,ris-backend-service/frontend
infra_repo: neuris-infra
deploy_key: ${{ secrets.DEPLOY_KEY }}
app: ris-production
argocd_pipeline_password: ${{ secrets.ARGOCD_PIPELINE_PASSWORD }}
argocd_server: ${{ secrets.ARGOCD_SERVER }}
argocd_sync_timeout: 300
- name: Track deploy
uses: digitalservicebund/track-deployment@5a2815e150e1268983aac5ca04c8c046ed1b614a # v1.0.0
with:
project: RIS
environment: production
metrics_deployment_webhook_url: ${{ secrets.METRICS_DEPLOYMENT_WEBHOOK_URL }}
metrics_webhook_token: ${{ secrets.METRICS_WEBHOOK_TOKEN }}
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
deploy-uat:
runs-on: ubuntu-latest
if: |
github.ref == 'refs/heads/main'
concurrency: deploy-uat
environment: uat
needs:
- push-frontend-image-to-registry
- push-backend-image-to-registry
- e2e-tests
- deploy-production
permissions:
id-token: write # Enable OIDC for gitsign
steps:
- uses: chainguard-dev/actions/setup-gitsign@0c26ac0ebfc8e53f8c2debe657cc2c5f6fe26663
- name: Deploy new images
uses: digitalservicebund/argocd-deploy@4fac1bb67c92ed168f6d9b22f8779ce241a9e412 # v1.0.0
with:
environment: uat
version: ${{ needs.push-backend-image-to-registry.outputs.version }}
deploying_repo: ris-backend-service,ris-backend-service/frontend
infra_repo: neuris-infra
deploy_key: ${{ secrets.DEPLOY_KEY }}
app: ris-uat
argocd_pipeline_password: ${{ secrets.ARGOCD_PIPELINE_PASSWORD }}
argocd_server: ${{ secrets.ARGOCD_SERVER }}
argocd_sync_timeout: 300
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
generate-entity-relationship-diagram:
runs-on: ubuntu-latest
if: ${{ false && github.ref == 'refs/heads/main' }}
env:
POSTGRES_DB: ris-erd
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: ris-erd
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name postgres
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Install uuid-ossp extension
run: docker exec postgres psql -d ${{ env.POSTGRES_DB }} -U ${{ env.POSTGRES_USER }} -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
- name: Apply incremental migration structure
run: docker exec -i postgres psql -d ${{ env.POSTGRES_DB }} -U ${{ env.POSTGRES_USER }} < ./backend/src/test/resources/db/create_migration_scheme_and_extensions.sql
- name: Get Gradle version
working-directory: ./backend
run: |
echo "GRADLE_VERSION=$(sed -n 's/.*gradle-\([0-9]*\(\.[0-9]*\)*\)-.*/\1/p' ./gradle/wrapper/gradle-wrapper.properties)" >> $GITHUB_ENV
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
with:
java-version: "21.0"
distribution: "temurin"
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Migrate database for Entity–relationship model
working-directory: ./backend
run: ./gradlew migrateDatabaseForERD
env:
DB_URL: jdbc:postgresql://localhost:5432/${{ env.POSTGRES_DB }}
DB_USER: ${{ env.POSTGRES_USER }}
DB_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
- name: Generate mermaid ER-diagram
uses: digitalservicebund/export-entity-relationship-diagram@c022c18a7a9e4fce71cece7ff907a952ba5c11c8
with:
configFile: ./backend/mermerd.config.yaml
connectionString: postgresql://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@localhost:5432/${{ env.POSTGRES_DB }}
outputFile: latest.mmd
flags: --debug
version: 0.9.0
- name: Upload mermaid ER-diagram
uses: actions/upload-artifact@v4
with:
name: erdiagram
retention-days: 3
path: latest.mmd
generate-backend-code-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
with:
java-version: "21.0"
distribution: "temurin"
cache: gradle
- name: Grant execute permission for gradlew
working-directory: ./backend
run: chmod +x gradlew
- name: Run Javadoc
working-directory: ./backend
run: ./gradlew javadoc
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: backend-code-documentation
retention-days: 3
path: backend/build/docs/javadoc/
- name: Send status to Slack
# Third-party action, pin to commit SHA!
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
push-reports:
runs-on: ubuntu-latest
needs:
# - generate-entity-relationship-diagram
- backend-build
- audit-licenses-backend
- audit-licenses-frontend
- e2e-tests
- generate-backend-code-documentation
- generate-test-reports
if: ${{ github.ref == 'refs/heads/main' }}
steps:
# Setup
- uses: actions/checkout@v4
with:
repository: ${{ env.REPORTS_REPOSITORY }}
ssh-key: ${{ secrets.REPORTS_DEPLOY_KEY }}
- name: Setup git config
run: |
git config user.name "${{ github.repository }}"
# This email identifies the commit as GitHub Actions - see https://github.com/orgs/community/discussions/26560
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# ER-diagram
# - name: ER-diagram - Download artifact
# uses: actions/download-artifact@v4
# with:
# name: erdiagram
# path: tmp/erdiagram-reports/
# - name: ER-diagram - git add report
# uses: digitalservicebund/add-ris-report@32770d369cf00a8154bb6a17005d11cf781bfba3
# with:
# filePath: tmp/erdiagram-reports/latest.mmd
# destinationDir: entity-relationship-diagrams/ris-backend-service
# Licence reports
- name: Licence reports - Download
uses: actions/download-artifact@v4
with:
pattern: licence-reports-*
path: tmp/licence-reports/
merge-multiple: true
- name: Frontend licence report - git add report
uses: digitalservicebund/add-ris-report@c6c8735d23295c36a271c75e7dedc9b6b9a9ef5e
with:
filePath: tmp/licence-reports/frontend-licence-report.csv
destinationDir: licence-reports/frontend/ris-backend-service
- name: Backend licence report - git add report
uses: digitalservicebund/add-ris-report@c6c8735d23295c36a271c75e7dedc9b6b9a9ef5e
with:
filePath: tmp/licence-reports/backend-licence-report.csv
destinationDir: licence-reports/backend/ris-backend-service
# Performance report
- name: Performance reports - Download
uses: actions/download-artifact@v4
with:
name: performance-report
path: tmp/performance-reports/
- run: mv tmp/performance-reports/profile*.html tmp/performance-reports/profile-report.html
- name: Performance report - git add report
uses: digitalservicebund/add-ris-report@c6c8735d23295c36a271c75e7dedc9b6b9a9ef5e
with:
filePath: tmp/performance-reports/profile-report.html
destinationDir: performance-reports/ris-backend-service
# Backend code documentation
- name: Backend Code Documentation - Download
uses: actions/download-artifact@v4
with:
name: backend-code-documentation
path: tmp/backend-code-documentation/
- name: Java - git add report
uses: digitalservicebund/add-ris-report@c6c8735d23295c36a271c75e7dedc9b6b9a9ef5e
with:
filePath: tmp/backend-code-documentation
destinationDir: backend-code-documentation/java
reportIsDirectory: true
# e2e test report
- name: E2E test reports - Download
uses: actions/download-artifact@v4
with:
name: html-test-report
path: tmp/html-test-report/
- name: E2E test reports - git add report
uses: digitalservicebund/add-ris-report@c6c8735d23295c36a271c75e7dedc9b6b9a9ef5e
with:
filePath: tmp/html-test-report/
destinationDir: test-reports/ris-backend-service
reportIsDirectory: true
# Push reports
- name: Push reports
# we use `toJSON(...)` below to escape double quotation marks
run: |
git diff-index --cached --quiet HEAD ||
git commit \
-m ${{ toJSON(github.event.head_commit.message) }} \
-m "From commit: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}" &&
git push origin main &&
echo "Pushed reports to ${{ github.server_url }}/${{ env.REPORTS_REPOSITORY }}" >> $GITHUB_STEP_SUMMARY