Skip to content

Commit 3a58760

Browse files
committed
feat: add Trivy container vulnerability scan after push
1 parent 92a2dbb commit 3a58760

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ on:
6060

6161
permissions:
6262
contents: read
63+
security-events: write
6364

6465
env:
6566
FULL_IMAGE: ${{ inputs.registry-host }}/${{ inputs.image-path }}/${{ inputs.component }}
@@ -149,3 +150,19 @@ jobs:
149150
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' "${{ env.FULL_IMAGE }}:${{ steps.meta.outputs.tag }}" 2>/dev/null | cut -d@ -f2 || echo "")
150151
echo "digest=${DIGEST}" >> "$GITHUB_OUTPUT"
151152
echo "Pushed: ${{ env.FULL_IMAGE }}:${{ steps.meta.outputs.tag }}"
153+
154+
# --- Trivy vulnerability scan ---
155+
- name: Run Trivy vulnerability scanner
156+
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0
157+
with:
158+
image-ref: "${{ env.FULL_IMAGE }}:${{ steps.meta.outputs.tag }}"
159+
format: "sarif"
160+
output: "trivy-results.sarif"
161+
severity: "HIGH,CRITICAL"
162+
exit-code: "0"
163+
164+
- name: Upload Trivy scan results to GitHub Security tab
165+
uses: github/codeql-action/upload-sarif@b0c4fd77f6c559021d78430ec4d0d169ae74a4eb # v3
166+
with:
167+
sarif_file: "trivy-results.sarif"
168+
if: always()

0 commit comments

Comments
 (0)