refactor cicd pipeline
All checks were successful
Build and Deploy Demo App / test (push) Successful in 11s
Build and Deploy Demo App / build (push) Successful in 7s
Build and Deploy Demo App / scan (push) Successful in 26s
Build and Deploy Demo App / deploy (push) Successful in 37s

This commit is contained in:
2025-11-26 13:11:55 +03:30
parent c473ffbd16
commit 1f2e223b42

View File

@@ -6,7 +6,7 @@ on:
- main - main
jobs: jobs:
# ------------------ TEST ------------------ # ---------- TEST ----------
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -16,19 +16,19 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.12' python-version: "3.12"
- name: Install deps - name: Install deps
run: pip install -r requirements.txt run: pip install -r requirements.txt
- name: Run tests - name: Run tests
env: env:
DB_USER: '' # force SQLite fallback DB_USER: "" # force SQLite fallback
DB_PASS: '' DB_PASS: ""
DB_NAME: '' DB_NAME: ""
run: pytest run: pytest
# ------------------ BUILD ------------------ # ---------- BUILD ----------
build: build:
needs: test needs: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -39,7 +39,7 @@ jobs:
- name: Build Docker image - name: Build Docker image
run: docker build -t demo-app:latest . run: docker build -t demo-app:latest .
# ------------------ SCAN ------------------ # ---------- SCAN ----------
scan: scan:
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -51,15 +51,14 @@ jobs:
- name: Build Docker image for scan - name: Build Docker image for scan
run: docker build -t demo-app:latest . run: docker build -t demo-app:latest .
# Use Trivy via Docker, no GitHub-specific action
- name: Scan image with Trivy - name: Scan image with Trivy
run: | run: |
docker run --rm \ docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
aquasecurity/trivy:latest \ aquasec/trivy:latest \
image --exit-code 1 --severity CRITICAL,HIGH demo-app:latest image --exit-code 1 --severity CRITICAL,HIGH --no-progress demo-app:latest
# ------------------ DEPLOY ------------------ # ---------- DEPLOY ----------
deploy: deploy:
needs: [build, scan] needs: [build, scan]
runs-on: ubuntu-latest runs-on: ubuntu-latest