mirror of
https://github.com/patrickbeane/vuln-summary.git
synced 2026-03-28 09:45:31 +00:00
fix: hybrid workflow to update JSON + README
This commit is contained in:
19
.github/workflows/update-vuln-summary.yml
vendored
19
.github/workflows/update-vuln-summary.yml
vendored
@@ -15,22 +15,31 @@ jobs:
|
|||||||
- name: Fetch sanitized JSON
|
- name: Fetch sanitized JSON
|
||||||
run: |
|
run: |
|
||||||
curl -sSL https://vuln.beane.me/json/trivy_sanitized.json -o trivy_sanitized.json
|
curl -sSL https://vuln.beane.me/json/trivy_sanitized.json -o trivy_sanitized.json
|
||||||
|
ls -lh trivy_sanitized.json
|
||||||
|
head -20 trivy_sanitized.json || true
|
||||||
|
|
||||||
- name: Extract last scan summary
|
- name: Extract last scan JSON
|
||||||
id: summary
|
|
||||||
run: |
|
run: |
|
||||||
summary=$(jq -r '"Last scan: \(.date) - Critical: \(.critical) | High: \(.high) | Medium: \(.medium) | Low: \(.low) | Total: \(.total)"' trivy_sanitized.json)
|
# Save the structured last_scan block for machine readability
|
||||||
|
jq '.last_scan' trivy_sanitized.json > latest.json
|
||||||
|
cat latest.json
|
||||||
|
|
||||||
|
- name: Build summary string
|
||||||
|
run: |
|
||||||
|
# Pull fields out for a one-liner summary
|
||||||
|
summary=$(jq -r '.last_scan | "Last scan: \(.date) — Critical: \(.critical) | High: \(.high) | Medium: \(.medium) | Low: \(.low) | Total: \(.total)"' trivy_sanitized.json)
|
||||||
echo "SUMMARY=$summary" >> $GITHUB_ENV
|
echo "SUMMARY=$summary" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Update README
|
- name: Update README
|
||||||
run: |
|
run: |
|
||||||
sed -i '/<!-- vuln-summary-start -->/,/<!-- vuln-summary-end -->/c\<!-- vuln-summary-start -->\n_${SUMMARY}_\n<!-- vuln-summary-end -->' README.md
|
sed -i '/<!-- vuln-summary-start -->/,/<!-- vuln-summary-end -->/c\<!-- vuln-summary-start -->\n_${SUMMARY}_\n<!-- vuln-summary-end -->' README.md
|
||||||
|
|
||||||
- name: Commit updated summary
|
- name: Commit updated files
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
mkdir -p data
|
||||||
mv latest.json data/last-scan.json
|
mv latest.json data/last-scan.json
|
||||||
git add data/last-scan.json
|
git add data/last-scan.json README.md
|
||||||
git commit -m "chore: update vuln summary [skip ci]" || echo "No changes to commit"
|
git commit -m "chore: update vuln summary [skip ci]" || echo "No changes to commit"
|
||||||
git push
|
git push
|
||||||
|
|||||||
Reference in New Issue
Block a user