This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (161 loc) · 5.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
name: Project CI
on:
push:
branches:
- '*'
- '*/*'
- '**'
tags-ignore:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate:
name: Validate Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache Maven
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-test-
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: "17"
cache: "maven"
- name: Code Validation
run: mvn -B validate --file pom.xml
- name: Archive CycloneDX
uses: actions/upload-artifact@v2
with:
name: cyclone
path: target/bom.json
retention-days: 5
- name: Code Compilation
run: mvn -B clean compile --file pom.xml
- name: Checkstyle
run: mvn -B checkstyle:checkstyle -Dcheckstyle.skip=false --file pom.xml
- name: Use Checkstyle report
uses: jwgmeligmeyling/checkstyle-github-action@master
with:
path: '**/checkstyle-result.xml'
test:
name: Test Code
runs-on: ubuntu-latest
needs:
- validate
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache Maven
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-test-
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: "17"
cache: "maven"
- name: Unit Tests
run: mvn -B test --file pom.xml
- name: Integration Tests
run: mvn -B verify -P integration-test --file pom.xml
artifact:
name: Build artifact
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Cache Maven
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-test-
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
server-id: 'github'
settings-path: ${{ github.workspace }}
- name: Generate Artifact
run: mvn -B clean package -DskipTests -Dtests.skip=true -Dskip.unit.tests=true --file pom.xml
- name: Publish Spring
run: mvn -B source:jar javadoc:jar deploy --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Saving artifact
uses: actions/upload-artifact@master
with:
name: service
path: target/simple-webflux*.jar
retention-days: 1
push_to_registry:
name: Push Docker image
runs-on: ubuntu-latest
needs:
- artifact
if: startsWith(github.ref_name,'v')
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Getting artifact
uses: actions/download-artifact@v3
with:
name: service
path: ./
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: |
ghcr.io/${{ github.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image Scan
uses: aquasecurity/[email protected]
continue-on-error: true
with:
image-ref: ghcr.io/${{ github.repository }}
ignore-unfixed: true
severity: CRITICAL
format: 'sarif'
output: 'docker-result.sarif'
- name: Upload Security results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
with:
sarif_file: "docker-result.sarif"