-
Notifications
You must be signed in to change notification settings - Fork 74
196 lines (165 loc) · 6.63 KB
/
maven-build.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
name: Maven Build
on:
push:
branches:
- v1.x
- v2.x
- develop
- develop-*
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Cache maven repository
uses: actions/cache@v4
with:
path: |
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 21
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%dT%H:%M:%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Restore CVD Database from Cache
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository/org/owasp/dependency-check-data
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
restore-keys: ${{ runner.os }}-maven-owasp-cvedb
- name: Update CVD Database
continue-on-error: true
env:
OWASP_OSS_INDEX_USERNAME: ${{ secrets.OWASP_OSS_INDEX_USERNAME }}
OWASP_OSS_INDEX_APIKEY: ${{ secrets.OWASP_OSS_INDEX_APIKEY }}
NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
run: |
mvn -B -P owasp -DnvdApiDelay=6000 --settings maven-ci-settings.xml org.owasp:dependency-check-maven:update-only
- name: Save CVD Database to Cache
uses: actions/cache/save@v4
with:
path: |
~/.m2/repository/org/owasp/dependency-check-data
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
- name: Check OWASP
env:
OWASP_OSS_INDEX_USERNAME: ${{ secrets.OWASP_OSS_INDEX_USERNAME }}
OWASP_OSS_INDEX_APIKEY: ${{ secrets.OWASP_OSS_INDEX_APIKEY }}
NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
run: |
mvn -B -DskipTests -Dmaven.javadoc.skip=true -P owasp -DautoUpdate=false --settings maven-ci-settings.xml org.owasp:dependency-check-maven:aggregate
- name: Build with Maven
run: |
mvn -B -DskipTests -Dmaven.javadoc.skip=true install
- name: Test with Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn -B verify sonar:sonar -Dsonar.projectKey=FraunhoferIOSB_FROST-Server -Dmaven.javadoc.skip=true -P coverage
echo "Exporting Variables"
export HTTP_NAME=$(mvn -pl FROST-Server.HTTP -Dexec.executable='echo' -Dexec.args='${project.build.finalName}' exec:exec -q)
export MQTTP_NAME=$(mvn -pl FROST-Server.MQTTP -Dexec.executable='echo' -Dexec.args='${project.build.finalName}' exec:exec -q)
export MQTT_NAME=$(mvn -pl FROST-Server.MQTT -Dexec.executable='echo' -Dexec.args='${project.build.finalName}' exec:exec -q)
echo "HTTP_ARTIFACT=${HTTP_NAME}.war" >> $GITHUB_ENV
echo "MQTTP_ARTIFACT=${MQTTP_NAME}.war" >> $GITHUB_ENV
echo "MQTT_ARTIFACT=${MQTT_NAME}-jar-with-dependencies.jar" >> $GITHUB_ENV
export version=$(mvn -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -q)
echo "DOCKER_TAG_MASTER=${version}" >> $GITHUB_ENV
echo "DOCKER_TAG_BRANCH=${GITHUB_REF:11}-${version}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push - HTTP - Master branch latest
if: github.ref == 'refs/heads/v2.x'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: "./FROST-Server.HTTP"
push: true
build-args: |
ARTIFACT_FILE=${{ env.HTTP_ARTIFACT }}
tags: |
fraunhoferiosb/frost-server-http:latest
fraunhoferiosb/frost-server-http:${{ env.DOCKER_TAG_MASTER }}
- name: Build and push - MQTTP - Master branch latest
if: github.ref == 'refs/heads/v2.x'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: "./FROST-Server.MQTTP"
push: true
build-args: |
ARTIFACT_FILE=${{ env.MQTTP_ARTIFACT }}
tags: |
fraunhoferiosb/frost-server-mqttp:latest
fraunhoferiosb/frost-server-mqttp:${{ env.DOCKER_TAG_MASTER }}
fraunhoferiosb/frost-server:latest
fraunhoferiosb/frost-server:${{ env.DOCKER_TAG_MASTER }}
- name: Build and push - MQTT - Master branch latest
if: github.ref == 'refs/heads/v2.x'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: "./FROST-Server.MQTT"
push: true
build-args: |
ARTIFACT_FILE=${{ env.MQTT_ARTIFACT }}
tags: |
fraunhoferiosb/frost-server-mqtt:latest
fraunhoferiosb/frost-server-mqtt:${{ env.DOCKER_TAG_MASTER }}
- name: Build and push - HTTP - Develop branch latest
if: startsWith(github.ref, 'refs/heads/develop')
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: "./FROST-Server.HTTP"
push: true
build-args: |
ARTIFACT_FILE=${{ env.HTTP_ARTIFACT }}
tags: |
fraunhoferiosb/frost-server-http:${{ env.DOCKER_TAG_BRANCH }}
- name: Build and push - MQTTP - Develop branch latest
if: startsWith(github.ref, 'refs/heads/develop')
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: "./FROST-Server.MQTTP"
push: true
build-args: |
ARTIFACT_FILE=${{ env.MQTTP_ARTIFACT }}
tags: |
fraunhoferiosb/frost-server:${{ env.DOCKER_TAG_BRANCH }}
fraunhoferiosb/frost-server-mqttp:${{ env.DOCKER_TAG_BRANCH }}
- name: Build and push - MQTT - Develop branch latest
if: startsWith(github.ref, 'refs/heads/develop')
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: "./FROST-Server.MQTT"
push: true
build-args: |
ARTIFACT_FILE=${{ env.MQTT_ARTIFACT }}
tags: |
fraunhoferiosb/frost-server-mqtt:${{ env.DOCKER_TAG_BRANCH }}