image tag fix #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: DevSecOps CI/CD Pipeline | |
| permissions: | |
| contents: write | |
| actions: write | |
| pull-requests: write | |
| issues: write | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - 'kubernetes/deployment.yaml' | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| name: Unit Testing | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install -r app/requirements.txt | |
| pip install pytest | |
| - name: Run tests | |
| run: pytest tests/ || echo "No tests yet" | |
| lint: | |
| name: SAST & Secrets Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Gitleaks Secret Scan | |
| uses: gitleaks/gitleaks-action@v2 | |
| build: | |
| name: Build Application | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create build artifact | |
| run: | | |
| mkdir build | |
| cp -r app/requirements.txt build/ | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-build | |
| path: build/ | |
| docker: | |
| name: Docker Build, Scan & Push | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| outputs: | |
| image_tag: ${{ steps.set_output.outputs.image_tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: app-build | |
| path: . | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=sha,format=long | |
| type=ref,event=branch | |
| latest | |
| # 🔧 FIX |