Skip to content

Commit 281f0b5

Browse files
committed
feat(ci): add trivy workflow
1 parent 6dace0f commit 281f0b5

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/trivy.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Trivy - Scan for vulnerabilities"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [main]
9+
schedule:
10+
# Runs every Monday morning PST
11+
- cron: "17 15 * * 1"
12+
13+
jobs:
14+
scan-repo:
15+
name: Scan repository
16+
runs-on: ubuntu-20.04
17+
steps:
18+
- name: Checkout code
19+
- uses: actions/checkout@v2
20+
21+
- name: Run Trivy vulnerability scanner in repo mode
22+
uses: aquasecurity/trivy-action@master
23+
with:
24+
scan-type: "fs"
25+
ignore-unfixed: true
26+
format: "template"
27+
template: "@/contrib/sarif.tpl"
28+
output: "trivy-repo-results.sarif"
29+
severity: "CRITICAL"
30+
31+
- name: Upload Trivy scan results to GitHub Security tab
32+
uses: github/codeql-action/upload-sarif@v1
33+
with:
34+
sarif_file: "trivy-repo-results.sarif"
35+
36+
scan-image:
37+
name: Scan Docker image
38+
runs-on: ubuntu-20.04
39+
steps:
40+
- name: Checkout code
41+
- uses: actions/checkout@v2
42+
43+
- name: Build an image from Dockerfile
44+
run: |
45+
docker build -t codercom/code-server:${{ github.sha }} --file ./ci/release-image/Dockerfile .
46+
47+
- name: Run Trivy vulnerability scanner in image mode
48+
uses: aquasecurity/trivy-action@master
49+
with:
50+
image-ref: "codercom/code-server:${{ github.sha }}"
51+
scan-type: "image"
52+
ignore-unfixed: true
53+
format: "template"
54+
template: "@/contrib/sarif.tpl"
55+
output: "trivy-image-results.sarif"
56+
severity: "CRITICAL"
57+
58+
- name: Upload Trivy scan results to GitHub Security tab
59+
uses: github/codeql-action/upload-sarif@v1
60+
with:
61+
sarif_file: "trivy-image-results.sarif"

0 commit comments

Comments
 (0)