Scan Docker image for vulnerabilities #888
This file contains 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: Scan Docker image for vulnerabilities | |
on: | |
schedule: | |
- cron: '30 7 * * *' | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
scan-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Docker image metadata | |
id: meta | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 | |
with: | |
images: operator | |
tags: | | |
type=sha,format=long | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 | |
with: | |
platforms: amd64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | |
- name: Build and load Docker image | |
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | |
with: | |
platforms: linux/amd64 | |
push: false | |
load: true | |
build-args: | |
BIN_NAME=${{ vars.BIN_NAME }} | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0 | |
with: | |
scan-type: image | |
format: sarif | |
image-ref: ${{ steps.meta.outputs.tags }} | |
output: 'trivy-results.sarif' | |
exit-code: '1' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@c4fb451437765abf5018c6fbf22cce1a7da1e5cc # codeql-bundle-v2.17.1 | |
with: | |
category: 'Trivy Security Scan' | |
sarif_file: 'trivy-results.sarif' |