-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (90 loc) · 2.84 KB
/
ci.yml
File metadata and controls
104 lines (90 loc) · 2.84 KB
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
name: Build and Publish
on:
push:
branches:
- '**'
tags:
- '*'
pull_request:
branches:
- main
env:
IMAGE_NAME: flex420/urlaubsverwaltung
jobs:
ci:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Cache Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('app/urlaubsverwaltung/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-
- name: Run unit tests
working-directory: app/urlaubsverwaltung
run: ./mvnw -B -DskipITs test
- name: Verify Docker and Compose
run: bash ./scripts/verify.sh
- name: Extract project version
id: version
working-directory: app/urlaubsverwaltung
run: |
VERSION=$(./mvnw -q help:evaluate -Dexpression=project.version -DforceStdout)
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
if [[ "$VERSION" == *-SNAPSHOT ]]; then
echo "sanitized=${VERSION%-SNAPSHOT}" >> "$GITHUB_OUTPUT"
else
echo "sanitized=${VERSION}" >> "$GITHUB_OUTPUT"
fi
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=sha-
type=ref,event=branch
type=raw,value=${{ steps.version.outputs.sanitized }},enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Login to Docker Hub
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Build and (optionally) push image
id: build
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' }}
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
format: spdx-json
output-file: sbom.spdx.json
- name: Upload SBOM artifact
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.spdx.json