forked from hapifhir/hapi-fhir-jpaserver-starter
-
Notifications
You must be signed in to change notification settings - Fork 23
115 lines (96 loc) · 3.87 KB
/
googleregistry.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
name: Build and Upload to Google Artifact registry
on:
workflow_dispatch:
push:
tags:
- "*"
env:
PROJECT_ID: ahdis-ch
GAR_LOCATION: europe-west6
REPOSITORY: ahdis
IMAGE: matchbox
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
id-token: write
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: adopt
cache: maven
- run: mvn --batch-mode --update-snapshots package -DskipTests -P release
- name: Set up QEMU
uses: docker/setup-qemu-action@master
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
# Configure Workload Identity Federation and generate an access token.
- id: "auth"
name: "Authenticate to Google Cloud"
uses: google-github-actions/auth@v2
with:
token_format: "access_token"
workload_identity_provider: "projects/1022310475153/locations/global/workloadIdentityPools/github-wif-pool/providers/oidc-github-provider"
service_account: "[email protected]"
- name: Docker configuration
run: |-
echo ${{steps.auth.outputs.access_token}} | docker login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev
# Build the Docker image for arm and amd
- name: Build
run: |-
docker buildx build \
--tag "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_REF_NAME" \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" \
--push \
--platform=linux/arm64,linux/amd64 \
-f matchbox-server/Dockerfile \
matchbox-server
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:${{ github.ref_name }}'
format: 'sarif'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@main
if: always()
with:
sarif_file: 'trivy-results.sarif'
- name: Send a stream message to Zulip
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIPAPIKEY }}
email: "[email protected]"
organization-url: "https://chat.fhir.org"
to: "matchbox"
type: "stream"
topic: "new matchbox version published"
content: |
:rocket: ${{ env.REPOSITORY }}/${{ env.IMAGE }}:${{ github.ref_name }} published :rocket:
see also https://github.com/ahdis/matchbox/releases/tag/${{ github.ref_name }}
docker pull ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:${{ github.ref_name }}
- name: Send a stream message to Zulip
uses: zulip/github-actions-zulip/send-message@v1
if: failure()
with:
api-key: ${{ secrets.ZULIPAPIKEY }}
email: "[email protected]"
organization-url: "https://chat.fhir.org"
to: "ahdis"
type: "stream"
topic: "failed publishing matchbox"
content: |
failure ${{ env.REPOSITORY }}/${{ env.IMAGE }}:${{ github.ref_name }}
see https://github.com/ahdis/matchbox/actions/runs/${{ github.run_id }}