Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/standard-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@ jobs:
--ignore-unfixed="${TRIVY_IGNORE_UNFIXED}" \
"${IMAGE_TO_SCAN}"

- name: Upload trivy report to step summary and truncate PR comment if too long
if: ${{ github.event_name == 'pull_request' && inputs.enable-trivy-scan }}
env:
SUMMARY_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
IS_FORK: "${{ github.event.pull_request.head.repo.fork }}"
run: |
cat trivy-pr-report.md >> "$GITHUB_STEP_SUMMARY"
# GitHub PR comments are limited to 65536 characters
MAX_PR_COMMENT_SIZE=65536
report_size=$(wc -c < trivy-pr-report.md)
if [ "$IS_FORK" != "true" ] && [ "$report_size" -gt "$MAX_PR_COMMENT_SIZE" ]; then
printf "The Trivy vulnerability report is too large to display as a PR comment.\n\nPlease view the full report in the [workflow run summary](%s).\n" "$SUMMARY_URL" > trivy-pr-report.md
fi
Comment thread
chgl marked this conversation as resolved.

- name: Add trivy report PR comment
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
# when running from a fork, the CI token doesn't have enough permissions to create PR comments
Expand Down