Skip to content

Commit ed2f27a

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

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/trivy.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
format: 'template'
26+
template: '@/contrib/sarif.tpl'
27+
output: 'trivy-repo-results.sarif'
28+
severity: 'CRITICAL'
29+
30+
- name: Upload Trivy scan results to GitHub Security tab
31+
uses: github/codeql-action/upload-sarif@v1
32+
with:
33+
sarif_file: 'trivy-repo-results.sarif'
34+
35+
scan-image:
36+
name: Scan Docker image
37+
runs-on: ubuntu-20.04
38+
steps:
39+
- name: Checkout code
40+
- uses: actions/checkout@v2
41+
42+
- name: Build an image from Dockerfile
43+
run: |
44+
docker build -t codercom/code-server:${{ github.sha }} --file ./ci/release-image/Dockerfile .
45+
46+
- name: Run Trivy vulnerability scanner in image mode
47+
uses: aquasecurity/trivy-action@master
48+
with:
49+
scan-type: 'image'
50+
format: 'template'
51+
template: '@/contrib/sarif.tpl'
52+
output: 'trivy-image-results.sarif'
53+
severity: 'CRITICAL'
54+
55+
- name: Upload Trivy scan results to GitHub Security tab
56+
uses: github/codeql-action/upload-sarif@v1
57+
with:
58+
sarif_file: 'trivy-image-results.sarif'

0 commit comments

Comments
 (0)