Skip to content

Commit 146c88d

Browse files
committed
ci(github-actions): integrate Trivy security scanning into CI and releases
- Add a reusable Trivy security scan workflow triggered on pushes, pull requests, scheduled runs, and workflow calls - Integrate the Trivy scan into the release workflow and require it to complete before the release job runs - Configure the scan to fail on high and critical vulnerabilities and upload results to the GitHub Security tab Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent 571aa4e commit 146c88d

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ jobs:
88
test:
99
uses: ./.github/workflows/testing.yml
1010

11+
trivy:
12+
uses: ./.github/workflows/trivy.yml
13+
1114
publish:
12-
needs: test
15+
needs: [test, trivy]
1316
runs-on: ubuntu-latest
1417
permissions:
1518
id-token: write

.github/workflows/trivy.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Trivy Security Scan
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
- cron: "0 15 * * *" # 23:00 UTC+8
10+
workflow_call:
11+
12+
jobs:
13+
trivy:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Trivy vulnerability scan
22+
uses: aquasecurity/trivy-action@0.35.0
23+
with:
24+
scan-type: fs
25+
scan-ref: .
26+
format: sarif
27+
output: trivy-results.sarif
28+
exit-code: 1
29+
severity: CRITICAL,HIGH
30+
31+
- name: Upload results to GitHub Security tab
32+
uses: github/codeql-action/upload-sarif@v3
33+
if: always()
34+
with:
35+
sarif_file: trivy-results.sarif

0 commit comments

Comments
 (0)