fix(workflow): inject summary directly into stream

This commit is contained in:
2025-10-05 21:26:18 -04:00
parent 89141a6b5b
commit f12d23d4f7

View File

@@ -10,6 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write # allow pushing back to the repo contents: write # allow pushing back to the repo
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -29,16 +30,17 @@ jobs:
- name: Build summary string - name: Build summary string
run: | run: |
{ jq -r '.last_scan | "_Last scan: \(.date)_\n\nCritical: \(.critical)\nHigh: \(.high)\nMedium: \(.medium)\nLow: \(.low)\n\nTotal: \(.total)"' trivy_sanitized.json > summary.txt
echo 'SUMMARY<<EOF'
jq -r '.last_scan | "_Last scan: \(.date)_\n\nCritical: \(.critical)\nHigh: \(.high)\nMedium: \(.medium)\nLow: \(.low)\n\nTotal: \(.total)"' trivy_sanitized.json
echo 'EOF'
} >> $GITHUB_ENV
- name: Update README - name: Update README
run: | run: |
awk -v summary="_${SUMMARY}_" ' awk '
/<!-- vuln-summary-start -->/ {print; print summary; skip=1; next} /<!-- vuln-summary-start -->/ {
print;
while ((getline line < "summary.txt") > 0) print line;
skip=1;
next
}
/<!-- vuln-summary-end -->/ {skip=0} /<!-- vuln-summary-end -->/ {skip=0}
!skip !skip
' README.md > README.tmp && mv README.tmp README.md ' README.md > README.tmp && mv README.tmp README.md