-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 1.8 KB
/
Copy pathbuild_and_push.yml
File metadata and controls
65 lines (54 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Source: https://github.com/Josep-Andreu/segur_cloud/blob/main/build-and-push.yaml
name: Build and Push to Quay
on:
push:
branches:
- main
env:
FULL_IMAGE: quay.io/mguzman98/jboss_lab:v1.0.0
jobs:
build-scan-push:
runs-on: ubuntu-latest
steps:
- name: 🧩 Checkout code
uses: actions/checkout@v4
- name: 🔧 Build container image
run: |
docker build -t $FULL_IMAGE .
- name: 🔍 Scan image with Trivy
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.FULL_IMAGE }}
severity: HIGH,CRITICAL
exit-code: 1
ignore-unfixed: true
# 🧾 Generate SBOM with Syft (syft-json format)
- name: 🧾 Generate SBOM (Syft)
run: |
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$PWD":/work \
anchore/syft:latest "$FULL_IMAGE" -o syft-json > sbom.syft.json
test -s sbom.syft.json && echo "SBOM created: sbom.syft.json"
- name: 📤 Upload SBOM artifact
uses: actions/upload-artifact@v4
with:
name: sbom-syft-json
path: sbom.syft.json
if-no-files-found: error
retention-days: 14
# 🛡 Evaluate SBOM with Grype (fail build on HIGH or CRITICAL vulns)
- name: 🛡 Vulnerability scan (Grype on SBOM)
run: |
docker run --rm \
-v "$PWD":/work \
anchore/grype:latest /work/sbom.syft.json \
--fail-on high \
--only-fixed=false \
--add-cpes-if-none
- name: 🔑 Login to Quay.io
run: |
docker login quay.io -u "${{ secrets.QUAY_USER }}" -p "${{ secrets.QUAY_PASSWORD }}"
- name: 🚀 Push image to Quay.io
run: |
docker push $FULL_IMAGE