44 push :
55 pull_request_target :
66 types : [labeled]
7- workflow_dispatch :
8- inputs :
9- tag :
10- description : ' Image Tag'
11- required : false
127
138env :
14- NODE_VERSION : 20
9+ NODE_VERSION : 22
1510 JAVA_VERSION : 21
1611
1712defaults :
@@ -20,28 +15,28 @@ defaults:
2015
2116jobs :
2217 test :
23- name : Build and Test
18+ name : Run Tests
2419 runs-on : ubuntu-latest
2520 steps :
26- - uses : actions/checkout@v4
21+ - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2722 with :
2823 fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
29- - uses : actions/setup-node@v4
24+ - uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3025 with :
3126 node-version : ${{ env.NODE_VERSION }}
3227 cache : ' npm'
3328 cache-dependency-path : frontend/package-lock.json
34- - name : Install npm dependencies
29+ - name : NPM install
3530 working-directory : frontend
36- run : npm install
31+ run : npm ci --ignore-scripts
3732 - name : Build and test frontend
3833 working-directory : frontend
39- run : npm test
34+ run : npm run test:coverage
4035 - name : Deploy frontend
4136 working-directory : frontend
4237 run : npm run dist
4338 - name : SonarCloud Scan Frontend
44- uses : SonarSource/sonarcloud-github -action@master
39+ uses : SonarSource/sonarqube-scan -action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6.0.0
4540 with :
4641 projectBaseDir : frontend
4742 args : >
@@ -54,51 +49,138 @@ jobs:
5449 env :
5550 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
5651 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
57- - uses : actions/setup-java@v4
52+ - uses : actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
5853 with :
5954 distribution : ' temurin'
6055 java-version : ${{ env.JAVA_VERSION }}
6156 cache : ' maven'
6257 - name : Cache SonarCloud packages
63- uses : actions/cache@v4
58+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
6459 with :
6560 path : ~/.sonar/cache
6661 key : ${{ runner.os }}-sonar
6762 restore-keys : ${{ runner.os }}-sonar
6863 - name : Build and test backend
6964 working-directory : backend
7065 run : >
71- mvn -B clean verify
66+ ./mvnw -B clean verify
7267 org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
7368 -Dsonar.projectKey=cryptomator_hub_backend
7469 -Dsonar.organization=cryptomator
7570 -Dsonar.host.url=https://sonarcloud.io
71+ --no-transfer-progress
7672 env :
7773 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7874 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
79- - id : get_tag
80- if : inputs.tag != '' || github.ref_type == 'tag' || contains(github.event.head_commit.message, '[build image]')
81- run : |
82- if [[ ! -z "${{ inputs.tag }}" ]]; then
83- TAG="${{ inputs.tag }}"
84- elif [[ ${{ github.ref_type }} == 'tag' || ${{ github.ref_name }} == 'develop' ]]; then
85- TAG="${{ github.ref_name }}"
86- else
87- TAG="commit-${{ github.sha }}"
88- fi
89- echo tag=${TAG} >> "$GITHUB_OUTPUT"
75+
76+ build-native-image :
77+ name : Build and Push ${{ matrix.arch }} Image
78+ needs : test
79+ if : startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[build image]')
80+ strategy :
81+ fail-fast : false
82+ matrix :
83+ include :
84+ - os : ubuntu-latest
85+ platform : linux/amd64
86+ arch : amd64
87+ - os : ubuntu-24.04-arm
88+ platform : linux/arm64
89+ arch : arm64
90+ runs-on : ${{ matrix.os }}
91+ outputs :
92+ digest_amd64 : ${{ steps.digest.outputs.digest_amd64 }}
93+ digest_arm64 : ${{ steps.digest.outputs.digest_arm64 }}
94+ permissions :
95+ contents : read
96+ packages : write
97+ steps :
98+ - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
99+ - uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
100+ with :
101+ node-version : ${{ env.NODE_VERSION }}
102+ cache : ' npm'
103+ cache-dependency-path : frontend/package-lock.json
104+ - name : NPM install
105+ working-directory : frontend
106+ run : npm ci --ignore-scripts
107+ - name : Deploy frontend
108+ working-directory : frontend
109+ run : npm run dist
90110 - name : Ensure to use tagged version
91- if : startsWith(github.ref, 'refs/tags/')
92- run : mvn versions:set --file ./backend/pom.xml -DnewVersion=${GITHUB_REF##*/}
93- - name : Build and push container image
94- if : github.event.inputs.tag != '' || startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[build image]')
95111 working-directory : backend
96- run : mvn -B clean package -DskipTests
112+ run : ./mvnw versions:set --file pom.xml -DnewVersion=${GITHUB_REF##*/}
113+ - name : Docker metadata
114+ id : meta
115+ uses : docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
116+ with :
117+ images : ghcr.io/cryptomator/hub
118+ tags : |
119+ type=sha,prefix=,format=short
120+ flavor : |
121+ suffix=-${{ matrix.arch }}
122+ labels : |
123+ org.opencontainers.image.title=Cryptomator Hub
124+ org.opencontainers.image.vendor=Skymatic GmbH
125+ - name : Set up Docker Buildx
126+ uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
127+ - name : Login to GHCR
128+ uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
129+ with :
130+ registry : ghcr.io
131+ username : ${{ github.actor }}
132+ password : ${{ secrets.GITHUB_TOKEN }}
133+ - name : Build and Push Container Image
134+ id : push
135+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
136+ with :
137+ context : backend
138+ file : backend/src/main/docker/Dockerfile.native
139+ platforms : ${{ matrix.platform }}
140+ tags : ${{ steps.meta.outputs.tags }}
141+ labels : ${{ steps.meta.outputs.labels }}
142+ push : true
143+ - name : Export Digest
144+ id : digest
145+ run : |
146+ echo "digest_${{ matrix.arch }}=${{ steps.push.outputs.digest }}" >> "$GITHUB_OUTPUT"
147+
148+ multi-arch-image :
149+ name : Build and Push Multi-Arch Image
150+ needs : build-native-image
151+ runs-on : ubuntu-latest
152+ permissions :
153+ id-token : write
154+ contents : read
155+ attestations : write
156+ packages : write
157+ steps :
158+ - name : Set up Docker Buildx
159+ uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
160+ - name : Determine short Commit SHA
161+ id : sha
162+ run : echo "short_sha=${LONG_SHA:0:7}" >> "$GITHUB_OUTPUT"
97163 env :
98- QUARKUS_JIB_PLATFORMS : linux/amd64,linux/arm64/v8
99- QUARKUS_CONTAINER_IMAGE_TAG : ${{ steps.get_tag.outputs.tag }}
100- QUARKUS_CONTAINER_IMAGE_BUILD : true
101- QUARKUS_CONTAINER_IMAGE_PUSH : true
102- QUARKUS_CONTAINER_IMAGE_REGISTRY : ghcr.io
103- QUARKUS_CONTAINER_IMAGE_USERNAME : ${{ github.actor }}
104- QUARKUS_CONTAINER_IMAGE_PASSWORD : ${{ secrets.GITHUB_TOKEN }}
164+ LONG_SHA : ${{ github.sha }}
165+ - name : Login to GHCR
166+ uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
167+ with :
168+ registry : ghcr.io
169+ username : ${{ github.actor }}
170+ password : ${{ secrets.GITHUB_TOKEN }}
171+ - name : Create Multi-Arch Manifest for ghcr.io/cryptomator/hub:${{ steps.sha.outputs.short_sha }}
172+ run : >
173+ docker buildx imagetools create --tag ghcr.io/cryptomator/hub:${{ steps.sha.outputs.short_sha }}
174+ ghcr.io/cryptomator/hub@${{ needs.build-native-image.outputs.digest_amd64 }}
175+ ghcr.io/cryptomator/hub@${{ needs.build-native-image.outputs.digest_arm64 }}
176+ - name : Retrieve Multi-Arch Digest
177+ id : inspect
178+ run : |
179+ DIGEST=$(docker buildx imagetools inspect ghcr.io/cryptomator/hub:${{ steps.sha.outputs.short_sha }} --format "{{json .Manifest}}" | jq -r .digest)
180+ echo "digest_multiarch=${DIGEST}" >> "$GITHUB_OUTPUT"
181+ - name : Generate artifact attestation
182+ uses : actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
183+ with :
184+ subject-name : ghcr.io/cryptomator/hub
185+ subject-digest : ${{ steps.inspect.outputs.digest_multiarch }}
186+ push-to-registry : true
0 commit comments