Improved Pipeline manifest
Some checks failed
Build and Deploy Demo App / test (push) Successful in 12s
Build and Deploy Demo App / build_scan_deploy (push) Failing after 10m42s

This commit is contained in:
2025-11-26 12:24:05 +03:30
parent 717b059670
commit 340d3ed95c

View File

@@ -6,6 +6,7 @@ on:
- main
jobs:
# 1) Run tests first
test:
runs-on: ubuntu-latest
steps:
@@ -27,7 +28,8 @@ jobs:
DB_NAME: ''
run: pytest
build:
# 2) Build image, scan it, and deploy (all on the same runner)
build_scan_deploy:
needs: test
runs-on: ubuntu-latest
steps:
@@ -47,28 +49,13 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@v6
with:
load: true
load: true # load image into local Docker
tags: demo-app:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Save Docker image to tar
run: docker save demo-app:latest > demo-app.tar
# demo-app.tar now lives in the shared workspace for later jobs
scan:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code (keep demo-app.tar)
uses: actions/checkout@v4
with:
clean: false # do NOT git clean; preserves demo-app.tar
- name: Load image from tar
run: docker load -i demo-app.tar
- name: Scan Image
# --- Security scan happens on the same runner as the build ---
- name: Scan image with Trivy
uses: aquasecurity/trivy-action@master
with:
image-ref: demo-app:latest
@@ -76,14 +63,11 @@ jobs:
exit-code: 1
severity: CRITICAL,HIGH
deploy:
needs: [build, scan]
runs-on: ubuntu-latest
steps:
# no checkout here so we don't accidentally clean demo-app.tar
# If Trivy finds HIGH/CRITICAL vulns, the step above fails and
# nothing below (including deploy) will run.
- name: Verify image tar exists
run: ls -lh demo-app.tar
- name: Save Docker image to tar
run: docker save demo-app:latest > demo-app.tar
- name: Set up SSH
run: |