Skip to content

Commit 1f0b414

Browse files
committed
Fixed output
1 parent dde5f4e commit 1f0b414

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

.github/workflows/action_publish-images-security-updates.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,25 @@ jobs:
4040
ignore-unfixed: true
4141
severity: 'CRITICAL,HIGH'
4242
hide-progress: true
43-
format: 'json' # For parsing
43+
format: 'json'
44+
output: 'trivy-results.json' # Explicitly specify output file
4445

4546
# Parse Trivy results to set has_vulnerabilities
4647
- if: inputs.skip_scan != true
4748
id: parse
49+
shell: bash
4850
run: |
49-
VULN_COUNT=$(cat trivy-results.json | jq '[.Results[] | select(.Vulnerabilities != null) | .Vulnerabilities[]] | length')
50-
if [ "$VULN_COUNT" -gt 0 ]; then
51-
echo "has_vulnerabilities=true" >> $GITHUB_OUTPUT
51+
if [ -f trivy-results.json ]; then
52+
VULN_COUNT=$(jq -r '[ .Results[] | select(.Vulnerabilities != null) | .Vulnerabilities[] ] | length // 0' trivy-results.json)
53+
if [ "${VULN_COUNT:-0}" -gt 0 ]; then
54+
echo "has_vulnerabilities=true" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "has_vulnerabilities=false" >> "$GITHUB_OUTPUT"
57+
fi
5258
else
53-
echo "has_vulnerabilities=false" >> $GITHUB_OUTPUT
59+
echo "Error: trivy-results.json not found"
60+
echo "has_vulnerabilities=false" >> "$GITHUB_OUTPUT"
61+
exit 1
5462
fi
5563
5664
get-latest-release:

0 commit comments

Comments
 (0)