How do you deploy only when images pass vulnerability scanning in GitHub Actions?
IntermediateProductionGitHub Actions and GitLab CI in Production
Answer
Scan the built image before pushing it to the trusted registry or promote it only after the scan: Trivy fails the job on findings above the threshold, and the deploy job needs the scan job.
- uses: aquasecurity/[email protected]
with:
image-ref: ghcr.io/acme/shop-api:${{ github.sha }}
severity: CRITICAL,HIGH
ignore-unfixed: true
exit-code: '1'
Maintain an expiring exceptions file (.trivyignore with justification and date) rather than lowering the threshold globally.
More on GitHub Actions and GitLab CI in Production
How do you organise reusable workflows for an organisation on GitHub?IntermediateHow do you reduce GitHub Actions minutes cost on private repos?IntermediateHow do you secure self-hosted runners?AdvancedHow do you design the GitHub Actions OIDC trust policy for AWS safely?AdvancedHow do you handle approvals and deployments across environments in GitHub Actions?IntermediateHow do you handle required checks when workflows use path filters or matrices?Advanced