-
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (162 loc) · 5.46 KB
/
dev-commit-stage.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
name: Commit Stage 🤖
on:
push:
branches: [ feature/*, develop ]
pull_request:
branches: [ main, develop ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
VERSION: ${{ github.sha }}
CI: CI
NATIVE_IMAGE_ENABLED: enabled
CI_GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
permissions:
packages: write
contents: write
issues: write
jobs:
validation:
name: Validation 👀
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate Gradle wrapper
uses: gradle/[email protected]
- name: Install Tools & Dependencies
uses: ./.github/actions/install/node
- name: Run Check
run: pnpm run check
build:
name: Build and Test 🧪
needs: [ validation ]
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: 🔍 CI_GITHUB_TOKEN
if: env.CI_GITHUB_TOKEN == ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "CI_GITHUB_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Java Tools & Dependencies
uses: ./.github/actions/install/java
with:
java-version: 21
gradle-arguments: build --scan
- name: Source code vulnerability scanning
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
format: 'sarif'
output: 'trivy-results-source-code.sarif'
- name: Upload vulnerability report
uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: 'trivy-results-source-code.sarif'
category: source-code
code-coverage:
name: Code Coverage 📊
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ env.CI_GITHUB_TOKEN }}
- name: Install Java Tools & Dependencies
uses: ./.github/actions/install/java
- name: Install Tools & Dependencies
uses: ./.github/actions/install/node
- name: Run Code Coverage
run: |
./gradlew koverXmlReport --no-daemon --stacktrace
- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build/reports/kover/report.xml
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
static-analysis-security:
name: 🔮 Static analysis and 🔒Security Checks
needs: [ validation ]
runs-on: ubuntu-latest
steps:
- name: 🔄 Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Java Tools & Dependencies
uses: ./.github/actions/install/java
- name: Install Tools & Dependencies
uses: ./.github/actions/install/node
- name: Check OWASP 🛡️
run: ./gradlew dependencyCheckAnalyze --no-daemon --stacktrace
- name: Upload owasp-report results 🛡️⬆️
uses: actions/upload-artifact@v4
with:
name: owasp-reports
path: build/reports/owasp
- name: Run detekt
run: ./gradlew detektAll --no-daemon --stacktrace
- name: Upload static reports artifact
uses: actions/[email protected]
with:
name: static-report
path: |
build/reports/detekt/detekt.xml
**/build/reports/lint-results-debug.xml
retention-days: 1
- name: Analyze detekt report
uses: github/codeql-action/[email protected]
with:
sarif_file: build/reports/detekt/detekt.sarif
checkout_path: ${{ github.workspace }}
package:
name: Package and Publish 📦
needs: [ build ]
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Java Tools & Dependencies
uses: ./.github/actions/install/java
- name: Execute Gradle build
run: |
chmod +x gradlew
./gradlew assemble
./gradlew bootBuildImage --imageName ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: OCI image vulnerability scanning
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
format: 'sarif'
output: 'trivy-results-oci-image.sarif'
- name: Upload vulnerability report
uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: 'trivy-results-oci-image.sarif'
- name: Log into container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ env.CI_GITHUB_TOKEN }}
- name: Publish container image
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: Publish container image (latest)
run: |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly