Skip to content

Trivy Scan

Trivy Scan #6

Workflow file for this run

name: Trivy Scan
on:
workflow_run:
workflows: ["Release Image"]
types: [completed]
jobs:
scan:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Pull production image
run: |
SHA=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)
echo "Pulling production image with SHA: ${SHA}"
docker pull ghcr.io/${{ github.repository }}:${SHA}
echo "IMAGE_REF=ghcr.io/${{ github.repository }}:${SHA}" >> $GITHUB_ENV
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@v0.35.0
with:
image-ref: ${{ env.IMAGE_REF }}
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
output: 'trivy-report.txt'
- name: Upload Trivy scan results
uses: actions/upload-artifact@v7
if: always()
with:
name: trivy-scan-report
path: trivy-report.txt