Add grype binary version checking #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: Build Docker Image | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| # Allow manual triggering | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| id: checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| id: setup | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| tags: grummage:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Test Docker image | |
| id: test | |
| run: docker run grummage --help | |
| - name: Generate SBOM | |
| if: github.event_name != 'pull_request' | |
| id: sbom | |
| uses: anchore/sbom-action@v0 | |
| with: | |
| image: grummage:latest | |
| format: syft-json | |
| output-file: "${{ github.event.repository.name }}-sbom.syft.json" | |
| - name: Generate SBOM (SPDX) | |
| if: github.event_name != 'pull_request' | |
| uses: anchore/sbom-action@v0 | |
| with: | |
| image: grummage:latest | |
| format: spdx-json | |
| output-file: "${{ github.event.repository.name }}-sbom.spdx.json" | |
| - name: Scan SBOM for vulnerabilities | |
| if: github.event_name != 'pull_request' | |
| id: scan | |
| uses: anchore/scan-action@v6 | |
| with: | |
| sbom: "${{ github.event.repository.name }}-sbom.syft.json" | |
| # output-file: "${{ github.event.repository.name }}-vuln.sarif.json" | |
| # Optional: fail the build on high severity or above vulnerabilities | |
| fail-build: false | |
| severity-cutoff: high | |
| - name: Upload SBOM as release asset | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| *-sbom.syft.json | |
| *-sbom.spdx.json | |
| *-vuln.sarif | |
| - name: Upload Anchore scan SARIF report | |
| if: github.event_name != 'pull_request' | |
| id: upload | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: ${{ steps.scan.outputs.sarif }} | |
| permissions: | |
| # Required to upload SARIF file to CodeQL. See: https://github.com/github/codeql-action/issues/2117 | |
| actions: read | |
| # Require writing security events to upload SARIF file to security tab | |
| security-events: write | |
| # Read commit contents | |
| contents: read |