-
Notifications
You must be signed in to change notification settings - Fork 22
59 lines (49 loc) · 1.46 KB
/
trivy-scan.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
name: Trivy Scan
on:
workflow_dispatch:
schedule:
- cron: "17 17 * * *"
permissions:
contents: read
jobs:
build:
permissions:
contents: read
security-events: write
name: Scan
runs-on: "ubuntu-latest"
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Get repository name
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "^1.19"
- name: Install tools
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
kustomize: "latest"
ko: "latest"
- name: Prepare build
run: make manifests generate
- name: Build container
env:
KO_DOCKER_REPO: ko.local
PLATFORMS: linux/amd64,linux/arm64,linux/arm
run: |
export SOURCE_DATE_EPOCH=$(date +%s)
ko build -B -t ${{ github.sha }} --platform=$PLATFORMS .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.15.0
with:
image-ref: "ko.local/${{ env.REPOSITORY_NAME }}:${{ github.sha }}"
format: "sarif"
output: "trivy-results.sarif"
severity: "CRITICAL,HIGH"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"