name: Docker Security Scan on: push: branches: [ main ] paths: - 'Dockerfile' - '.dockerignore' - 'package.json' - 'bun.lock*' pull_request: branches: [ main ] paths: - 'Dockerfile' - '.dockerignore' - 'package.json' - 'bun.lock*' schedule: - cron: '0 0 * * 0' # Run weekly on Sunday at midnight permissions: contents: read actions: read security-events: write jobs: scan: name: Scan Docker Image runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: network=host - name: Build Docker image uses: docker/build-push-action@v5 with: context: . push: false load: true tags: gitea-mirror:scan # Disable GitHub Actions cache for this workflow no-cache: true - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@0.28.0 with: image-ref: gitea-mirror:scan format: 'sarif' output: 'trivy-results.sarif' exit-code: '1' ignore-unfixed: false vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - name: Upload Trivy scan results to GitHub Security tab uses: github/codeql-action/upload-sarif@v3 if: always() with: sarif_file: 'trivy-results.sarif' - name: Run Trivy vulnerability scanner (table output) uses: aquasecurity/trivy-action@0.28.0 if: failure() with: image-ref: gitea-mirror:scan format: 'table' exit-code: '0' ignore-unfixed: false vuln-type: 'os,library' severity: 'CRITICAL,HIGH'