-
Notifications
You must be signed in to change notification settings - Fork 1
231 lines (203 loc) · 8.17 KB
/
ci.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
---
name: Application build and test
on:
push:
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
CDXGEN_VERSION: '11.0.7'
CDXGEN_PLUGINS_VERSION: '1.6.9'
GRYPE_VERSION: 'v0.86.1'
SBOMQS_VERSION: 'v0.2.3'
DEPSCAN_VERSION: 'v5.5.0'
NYDUS_VERSION: '2.3.0'
SWIFT_VERSION: '5.10.1'
semantic_version: '19.0.5'
java_version: '21'
node_version: '21'
mvn_parameter: '-B -ntp'
image_name: 'ghcr.io/mediamarktsaturn/technolinator'
jobs:
preparation:
name: Preparation
runs-on: ubuntu-latest
if: |
github.actor != 'dependabot[bot]' ||
(github.actor == 'dependabot[bot]' && github.ref != 'refs/heads/main')
outputs:
has_changes: ${{ steps.changed-files.outputs.any_changed }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get relevant changes
id: changed-files
uses: tj-actions/changed-files@v45
with:
files_ignore: |
**/*.md
docs/
.github/dependabot.yml
.github/technolinator.yml
skip_ci:
# Use the same name as CI build as workaround for required status checks for pull requests
# See https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
name: Application Build
runs-on: ubuntu-latest
needs: preparation
if: needs.preparation.outputs.has_changes == 'false'
steps:
- run: echo 'Skip build because no relevant files have been changed.'
ci:
name: Application Build
runs-on: ubuntu-latest-16-cores
needs: preparation
if: needs.preparation.outputs.has_changes == 'true'
steps:
- name: Free disk space
run: |
df -h
echo "----------------------------------------"
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version: '${{ env.node_version }}'
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '${{ env.java_version }}'
distribution: 'temurin'
- name: Install dependencies for semantic-release-action
run: npm install -D [email protected]
- name: Getting next release version
id: semantic
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: true
semantic_version: ${{ env.semantic_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install requirements
uses: ./.github/actions/install-requirements
with:
grype_version: ${{ env.GRYPE_VERSION }}
sbomqs_version: ${{ env.SBOMQS_VERSION }}
depscan_version: ${{ env.DEPSCAN_VERSION }}
nydus_version: ${{ env.NYDUS_VERSION }}
cdxgen_version: ${{ env.CDXGEN_VERSION }}
cdxgen_plugins_version: ${{ env.CDXGEN_PLUGINS_VERSION }}
- name: Application Build and Test
env:
sem_ver: ${{ steps.semantic.outputs.new_release_version }}
QUARKUS_GITHUB_APP_APP_ID: 32168
QUARKUS_GITHUB_APP_WEBHOOK_SECRET: for-my-eyes-only
QUARKUS_GITHUB_APP_PRIVATE_KEY: ''
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -n "$sem_ver" ]; then
mvn ${{ env.mvn_parameter }} versions:set -DnewVersion="$sem_ver"
fi
mvn ${{ env.mvn_parameter }} clean install
VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo VERSION="$VERSION" >> $GITHUB_ENV
- name: Publish Test Report
if: ${{ failure() }}
uses: scacap/action-surefire-report@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
fail_if_no_tests: false
create_check: false
- name: Static code analysis
if: github.ref == 'refs/heads/main' && steps.semantic.outputs.new_release_version != null
env:
SONAR_TOKEN: ${{ secrets.SONARQUBE_ANALYSIS_TOKEN }}
SONAR_HOST: ${{ secrets.SONARQUBE_HOST_URL }}
PROJECT_KEY: technolinator:main
run: |
mvn ${{ env.mvn_parameter }} org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.host.url="$SONAR_HOST" \
-Dsonar.login="$SONAR_TOKEN" \
-Dsonar.projectKey="$PROJECT_KEY" \
-Dsonar.coverage.jacoco.xmlReportPaths=target/jacoco-report/jacoco.xml
- name: Sanity versions
env:
GRYPE: ${{ env.GRYPE_VERSION }}
SBOMQS: ${{ env.SBOMQS_VERSION }}
run: |
echo "Sanity provided versions for docker build"
{
echo "GRYPE_VERSION=${GRYPE#v}"
echo "SBOMQS_VERSION=${SBOMQS#v}"
} >> "$GITHUB_ENV"
- name: Docker build
uses: docker/build-push-action@v6
with:
context: .
file: src/main/docker/Dockerfile
tags: ${{ env.image_name }}:${{ env.VERSION }}
load: true
build-args: |
CDXGEN_VERSION=${{ env.CDXGEN_VERSION }}
CDXGEN_PLUGINS_VERSION=${{ env.CDXGEN_PLUGINS_VERSION }}
GRYPE_VERSION=${{ env.GRYPE_VERSION }}
SBOMQS_VERSION=${{ env.SBOMQS_VERSION }}
NYDUS_VERSION=${{ env.NYDUS_VERSION }}
DEPSCAN_VERSION=${{ env.DEPSCAN_VERSION }}
- name: Container structure test and tagging
run: |
sudo curl -Lso /usr/local/bin/container-structure-test https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64
sudo chmod a+x /usr/local/bin/container-structure-test
container-structure-test test --config src/test/docker/structure-test.yaml --image ${{ env.image_name }}:${{ env.VERSION }}
# tag for tag image build
docker tag ${{ env.image_name }}:${{ env.VERSION }} technolinator:regular
- name: Docker fat image build
uses: docker/build-push-action@v6
with:
context: .
file: src/main/docker/Dockerfile.fat
tags: ${{ env.image_name }}:fat-${{ env.VERSION }}
load: true
build-args: |
SWIFT_VERSION=${{ env.SWIFT_VERSION }}
- name: Container structure test of fat image
run: |
container-structure-test test --config src/test/docker/structure-test.yaml --image ${{ env.image_name }}:fat-${{ env.VERSION }}
container-structure-test test --config src/test/docker/structure-test.fat.yaml --image ${{ env.image_name }}:fat-${{ env.VERSION }}
- name: Login to GHCR
uses: docker/login-action@v3
if: github.ref == 'refs/heads/main' && steps.semantic.outputs.new_release_version != null
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker push
if: github.ref == 'refs/heads/main' && steps.semantic.outputs.new_release_version != null
run: |
# upload images
docker push ${{ env.image_name }}:${{ env.VERSION }}
docker push ${{ env.image_name }}:fat-${{ env.VERSION }}
- name: Create and upload container SBOM
if: github.ref == 'refs/heads/main'
run: |
cdxgen -t container \
--server-url ${{ secrets.DTRACK_URL }} \
--api-key ${{ secrets.DTRACK_APIKEY }} \
--project-name technolinator_container \
--project-version 1 \
"${{ env.image_name }}:${{ env.VERSION }}"
- name: Create Release
if: github.ref == 'refs/heads/main' && steps.semantic.outputs.new_release_version != null
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: ${{ env.semantic_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}