Skip to content

Commit caabdd4

Browse files
committed
chore: enhance build workflow with Trivy vulnerability scanning and result upload
1 parent 32dbb27 commit caabdd4

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
build:
4343
needs: prepare
4444
runs-on: ubuntu-latest
45+
permissions:
46+
security-events: write
47+
packages: write
4548
strategy:
4649
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
4750
fail-fast: false
@@ -93,6 +96,7 @@ jobs:
9396
echo "tags=${TAGS%,}" >> $GITHUB_OUTPUT
9497
9598
- name: Build and push
99+
id: build
96100
uses: docker/build-push-action@v6
97101
with:
98102
context: .
@@ -106,6 +110,21 @@ jobs:
106110
cache-from: type=gha,scope=${{ matrix.name }}
107111
cache-to: type=gha,mode=max,scope=${{ matrix.name }}
108112

113+
- name: Run Trivy vulnerability scanner
114+
if: steps.build.outcome == 'success'
115+
uses: aquasecurity/trivy-action@master
116+
with:
117+
image-ref: ${{ env.DOCKER_HUB_IMAGE }}:${{ matrix.node_version }}-jdk${{ matrix.jdk_version }}
118+
format: 'sarif'
119+
output: 'trivy-results.sarif'
120+
sevegithub/codeql-action/upload-sarif@v4
121+
122+
- name: Upload Trivy scan results to GitHub Security tab
123+
uses: github/codeql-action/upload-sarif@v3
124+
if: steps.build.outcome == 'success'
125+
with:
126+
sarif_file: 'trivy-results.sarif'
127+
109128
update-readme:
110129
needs: build
111130
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)