Write a workflow step that scans the image with Trivy and fails on HIGH/CRITICAL vulnerabilities.
BeginnerHands-onWrite-a-pipeline tasks
Answer
- name: Scan image
uses: aquasecurity/[email protected]
with:
image-ref: myapp:${{ github.sha }}
severity: HIGH,CRITICAL
ignore-unfixed: true
exit-code: "1"
format: table
CLI equivalent: trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 myapp:tag.
Key trick → exit-code: 1 is what actually fails the build, because Trivy exits 0 by default. ignore-unfixed stops the gate blocking on CVEs nobody can patch yet. Pin the action to a version (or a SHA).
More on Write-a-pipeline tasks
Write a GitHub Actions workflow that runs tests on every PR and push to main.BeginnerWrite a workflow that builds a Docker image and pushes it to ECR using OIDC (no access keys).IntermediateWrite a matrix job that tests on Python 3.10, 3.11 and 3.12 on Linux and Windows.BeginnerWrite a declarative Jenkinsfile with build, test, Docker push and a manual approval before prod.AdvancedWrite a GitHub Actions deploy job that requires approval for production using environments.BeginnerWrite a reusable workflow and call it from another repo.Intermediate