-
Notifications
You must be signed in to change notification settings - Fork 8
76 lines (69 loc) · 2.18 KB
/
ci-trivy.yaml
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
name: CI - Trivy Scan
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
trivy-scan:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
context: ["docker/web", "docker/api"]
include:
- context: docker/web
context_path: .
image_name: scv-web
sarif_file: trivy-web.sarif
docker_file: docker/web/Dockerfile.release
docker_build_args: |
WEB_BASE_HREF=/
NGINX_RUNTIME_SRC=../../docker/nginx-runtime
VUE_ON_NGINX_SRC=../../docker/vue-on-nginx
WEB_SRC=../../web
- context: docker/api
context_path: .
image_name: scv-api
sarif_file: trivy-api.sarif
docker_file: docker/api/Dockerfile.release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Setup
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Build
uses: docker/build-push-action@v6
with:
context: ${{matrix.context_path}}
file: ${{matrix.docker_file}}
push: false
load: true
tags: ${{matrix.image_name}}:latest
build-args: ${{matrix.docker_build_args}}
- name: Run Trivy vulnerability scanner- save to sarif file
uses: aquasecurity/trivy-action@cf990b19d84bbbe1eb8833659989a7c1029132e3
with:
scan-type: image
image-ref: ${{matrix.image_name}}:latest
format: "template"
ignore-unfixed: true
template: "@/contrib/sarif.tpl"
output: ${{matrix.sarif_file}}
severity: CRITICAL,HIGH,MEDIUM,LOW
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{matrix.sarif_file}}