Skip to content

Commit b22daec

Browse files
committed
fix(ci): handle JSON string parsing in cleanup workflow
Add jq -Rr flags with fromjson? to properly parse JSON strings that may be passed as raw input rather than pre-parsed JSON objects. This prevents parsing failures when SHA_ONLY_RESULT contains JSON in string format.
1 parent 7de6c40 commit b22daec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.github/workflows/cleanup-ghcr-images.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ jobs:
318318
319319
if [ -n "$SHA_ONLY_RESULT" ] && [ "$SHA_ONLY_RESULT" != "null" ]; then
320320
AGE_DELETED=$(echo "$AGE_BASED_RESULT" | jq -r 'if type == "array" then length elif type == "object" then .ageBasedDeleted // 0 else 0 end')
321-
SHA_DELETED=$(echo "$SHA_ONLY_RESULT" | jq -r '.shaOnlyDeleted // 0')
322-
TOTAL_BEFORE=$(echo "$SHA_ONLY_RESULT" | jq -r '.totalBefore // 0')
323-
REMAINING=$(echo "$SHA_ONLY_RESULT" | jq -r '.remaining // 0')
321+
SHA_DELETED=$(echo "$SHA_ONLY_RESULT" | jq -Rr 'fromjson? // {} | .shaOnlyDeleted // 0')
322+
TOTAL_BEFORE=$(echo "$SHA_ONLY_RESULT" | jq -Rr 'fromjson? // {} | .totalBefore // 0')
323+
REMAINING=$(echo "$SHA_ONLY_RESULT" | jq -Rr 'fromjson? // {} | .remaining // 0')
324324
325325
echo "### Summary" >> $GITHUB_STEP_SUMMARY
326326
echo "| Metric | Count |" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)