Skip to content

Commit 8402786

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

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/trivy.yml

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

0 commit comments

Comments
 (0)