Skip to content

Commit 840a275

Browse files
authored
Update docker-security.yml
1 parent 6b0b9da commit 840a275

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
1-
name: 🔍 Validate Docker Image with Trivy (docker-compose)
1+
name: Trivy Image Scan
22

33
on:
4-
pull_request:
5-
branches: [master]
64
push:
7-
branches: [master]
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
89

910
jobs:
10-
build-and-scan:
11+
scan:
12+
name: Scan Docker Image with Trivy
1113
runs-on: ubuntu-latest
1214

1315
steps:
14-
- name: 🧾 Checkout repo
15-
uses: actions/checkout@v3
16-
17-
- name: 🐳 Set up Docker Compose
18-
run: sudo apt-get update && sudo apt-get install -y docker-compose
19-
20-
- name: 🛠️ Build image without cache
21-
run: docker compose build --no-cache
22-
23-
- name: 🐳 List Docker images (debug)
24-
run: docker images
25-
26-
- name: 🔍 Run Trivy via Docker (scan local image)
27-
run: |
28-
docker run --rm \
29-
-v /var/run/docker.sock:/var/run/docker.sock \
30-
-v $HOME/.cache:/root/.cache/ \
31-
aquasec/trivy:latest \
32-
image --format table --exit-code 1 --ignore-unfixed \
33-
--severity UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL \
34-
python-samples-fastapi-restful:latest
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Build image
23+
run: docker build -t python-samples-fastapi-restful .
24+
25+
- name: Install Trivy
26+
uses: aquasecurity/trivy-action@v0.16.1
27+
with:
28+
version: latest
29+
30+
- name: Run Trivy scan (como en Windows)
31+
run: trivy image --no-progress --format table -o trivy-report.txt python-samples-fastapi-restful
32+
33+
- name: Upload Trivy report
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: trivy-scan-report
37+
path: trivy-report.txt

0 commit comments

Comments
 (0)