diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06e0bb95..b2c5ddbb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -64,18 +64,6 @@ jobs: tags: 'ci/hdm:${{ github.sha }}' push: false - - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master - with: - image-ref: 'ci/hdm:${{ github.sha }}' - format: 'sarif' - output: 'trivy-results.sarif' - - - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: 'trivy-results.sarif' - tests: needs: - shellcheck diff --git a/.github/workflows/trivy-analysis.yml b/.github/workflows/trivy-analysis.yml new file mode 100644 index 00000000..68abba33 --- /dev/null +++ b/.github/workflows/trivy-analysis.yml @@ -0,0 +1,43 @@ +--- +name: Trivy + +on: + push: + branches: + - main + pull_request: + # The branches below must be a subset of the branches above + branches: + - main + + +jobs: + analyze: + name: 'Analyze' + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + tags: 'ci/hdm:${{ github.sha }}' + push: false + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'ci/hdm:${{ github.sha }}' + format: 'sarif' + output: 'trivy-results.sarif' + + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: 'trivy-results.sarif'