refactor(get-images-from-files): to return json array
This commit is contained in:
@@ -48,10 +48,11 @@ jobs:
|
||||
- get-images-from-files/test-values-helmfile.yaml
|
||||
- name: Check image formats extracted
|
||||
run: |
|
||||
images="${{ steps.giff.outputs.images }}"
|
||||
echo "Extracted: $images"
|
||||
images='${{ steps.giff.outputs.images }}'
|
||||
echo "JSON array (for manual inspection):"
|
||||
echo "$images" | jq .
|
||||
echo ""
|
||||
check() { echo -n " $1: "; echo "$images" | grep -q "$2" && echo "OK" || { echo "FAIL (not found)"; exit 1; }; }
|
||||
check() { echo -n " $1: "; echo "$images" | jq -e --arg ref "$2" 'index($ref) != null' >/dev/null && echo "OK" || { echo "FAIL (not found)"; exit 1; }; }
|
||||
|
||||
# Dockerfile-only refs
|
||||
check "Dockerfile registry+tag (nginx:v1)" "example.com/library/nginx:v1"
|
||||
@@ -72,10 +73,10 @@ jobs:
|
||||
|
||||
# Shared ref (in both files) — must appear exactly once
|
||||
check "Shared ref present (distroless/static:nonroot)" "example.com/distroless/static:nonroot"
|
||||
count=$(echo "$images" | tr ',' '\n' | grep -c 'example.com/distroless/static:nonroot' || true)
|
||||
count=$(echo "$images" | jq '[.[] | select(. == "example.com/distroless/static:nonroot")] | length')
|
||||
echo -n " Shared ref appears once (no duplicates): "
|
||||
[ "$count" -eq 1 ] && echo "OK (count=$count)" || { echo "FAIL (count=$count, expected 1)"; exit 1; }
|
||||
total=$(echo "$images" | tr ',' '\n' | grep -c . || true)
|
||||
total=$(echo "$images" | jq 'length')
|
||||
echo -n " Total unique refs: "
|
||||
[ "$total" -eq 10 ] && echo "OK ($total)" || { echo "FAIL (got $total, expected 10)"; exit 1; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user