File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 branches : [ "main" ]
88
99jobs :
10- build :
10+ docker_build :
1111 runs-on : ubuntu-latest
1212
1313 steps :
2525 - name : Build the Docker image
2626 run : docker build . --file Dockerfile --tag my-image-name:$(date +%s)
2727
28+ security_test :
29+ runs-on : ubuntu-latest
30+ needs : docker_build
31+ steps :
32+ - name : Check code
33+ uses : actions/checkout@v4
34+
35+ - name : Install Trivy
36+ run : |
37+ sudo apt-get update
38+ sudo apt-get install -y apt-transport-https
39+ curl -fsSL https://github.com/aquasecurity/trivy/releases/download/v0.35.0/trivy_0.35.0_Linux-64bit.deb -o trivy.deb
40+ sudo dpkg -i trivy.deb
41+ sudo apt-get update
42+ sudo apt-get install -f
43+
44+ - name : Scan Docker image for vulnerabilities using Trivy
45+ run : |
46+ # Trivy scan for vulnerabilities
47+ trivy image --no-progress my-image-name:$(date +%s)
48+
49+ - name : Fail the build on critical vulnerabilities (optional)
50+ run : |
51+ trivy image --exit-code 1 --no-progress my-image-name:$(date +%s)
52+
You can’t perform that action at this time.
0 commit comments