Skip to content

Commit d0e46ea

Browse files
authored
docker-pipeline
1 parent e251a66 commit d0e46ea

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

.github/workflows/docker-pipeline.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ "main" ]
88

99
jobs:
10-
build:
10+
docker_build:
1111
runs-on: ubuntu-latest
1212

1313
steps:
@@ -25,3 +25,28 @@ jobs:
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+

0 commit comments

Comments
 (0)