-
Notifications
You must be signed in to change notification settings - Fork 405
50 lines (42 loc) · 1.25 KB
/
trivy-scan.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
name: "Trivy Scan"
on:
pull_request:
branches: [ master ]
permissions:
contents: read
env:
IMAGE_REPO: openyurt
jobs:
images:
name: Image Scan
runs-on: ubuntu-22.04
strategy:
matrix:
target: [ yurthub, node-servant, yurt-manager, yurt-iot-dock ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
run: |
tag=$(git describe --abbrev=0 --tags)
commit=$(git rev-parse HEAD)
if $(git tag --points-at ${commit}); then
echo "git_tag=`echo ${tag}-$(echo ${commit} | cut -c 1-7)`" >> $GITHUB_ENV
else
echo "git_tag=`echo ${tag}`" >> $GITHUB_ENV
fi
make docker-build
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.IMAGE_REPO }}/${{ matrix.target }}:${{ env.git_tag }}'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'