Merge pull request #800 from Jayking40/main #13
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
| # .github/workflows/image-scan.yml | |
| # | |
| # Trivy image scan for backend and frontend Docker images. Runs after | |
| # the CI build (or directly on main pushes). Reports CRITICAL and HIGH | |
| # vulnerabilities but does not fail the build on unfixable upstream | |
| # CVEs, so security findings are visible without blocking delivery. | |
| name: Image Scan | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| scan: | |
| name: Trivy scan | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| security-events: write | |
| strategy: | |
| matrix: | |
| service: [backend, frontend] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ secrets.DOCKERHUB_USERNAME != '' && 'docker.io' || 'ghcr.io' }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_USERNAME || github.actor }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }} | |
| - uses: docker/setup-buildx-action@v4 | |
| - name: Build image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: ./${{ matrix.service }} | |
| file: ./${{ matrix.service }}/Dockerfile | |
| load: true | |
| tags: stellar-indigopay-${{ matrix.service }}:scan | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@v0.36.0 | |
| with: | |
| image-ref: stellar-indigopay-${{ matrix.service }}:scan | |
| format: "sarif" | |
| output: "trivy-${{ matrix.service }}.sarif" | |
| severity: "CRITICAL,HIGH" | |
| exit-code: "0" | |
| ignore-unfixed: true | |
| vuln-type: "os,library" | |
| trivyignores: ".trivyignore" | |
| - name: Upload Trivy scan results to GitHub Security tab | |
| if: always() | |
| uses: github/codeql-action/upload-sarif@v3 | |
| continue-on-error: true | |
| with: | |
| sarif_file: trivy-${{ matrix.service }}.sarif | |
| category: trivy-${{ matrix.service }} |