Skip to content

Commit e1740a4

Browse files
ci: create image and scan with trivy (#527)
1 parent c09aa47 commit e1740a4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/docker.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Scan Docker image
2+
on:
3+
push:
4+
branches-ignore:
5+
- gh-pages
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
- name: Build an image from Dockerfile
14+
run: docker build -t trivy-explorer .
15+
- name: Run Trivy vulnerability scanner
16+
uses: aquasecurity/[email protected]
17+
with:
18+
image-ref: "trivy-explorer"
19+
output: trivy-report.json
20+
format: json
21+
exit-code: "0"
22+
ignore-unfixed: true
23+
vuln-type: "os,library"
24+
severity: "CRITICAL"
25+
- name: Upload Vulnerability Scan Results
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: trivy-report
29+
path: trivy-report.json
30+
retention-days: 30
31+
- name: Output artifact URL
32+
run: echo 'Artifact URL is ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}'
33+
- name: Get the JSON Report Download URL
34+
id: get_report_url
35+
run: |
36+
repo_url="https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/trivy-report.json"
37+
echo "::set-output name=report_url::${repo_url}"
38+
- name: Display Vulnerability Report URL
39+
run: |
40+
echo "You can view the vulnerability report here:"
41+
echo "https://dbsystel.github.io/trivy-vulnerability-explorer/#/?url=${{ steps.get_report_url.outputs.report_url }}"

0 commit comments

Comments
 (0)