@@ -94,24 +94,27 @@ jobs:
9494
9595 # Handle arrays of URLs (e.g., screenshots)
9696 # Check if the field is an array using yq length check
97- is_array=$(echo "$metadata" | yq -r ".${field} | length")
98-
99- if [[ "$is_array" =~ ^[0-9]+$ && "$is_array" -gt 0 ]]; then
100- # Iterate properly over array elements
101- for url in $(echo "$metadata" | yq -r ".$field[]" || true); do
102- if [[ -z "$url" ]]; then # Skip empty values inside arrays
103- continue
104- fi
97+ local field_type
98+ field_type=$(echo "$metadata" | yq -r ".${field} | type")
99+
100+ if [[ "$field_type" == "!!seq" ]]; then
101+ # Extract array values and remove empty strings
102+ urls=$(echo "$metadata" | yq -r ".$field | map(select(. != null and . != \"\")) | .[]?" || true)
103+
104+ # If the array is empty or contains only empty strings, trigger an error for required fields
105+ if [[ -z "$urls" && "$required" == "required" ]]; then
106+ echo "::error file=$metadata_file::'$field' is required but missing"
107+ ((errors++))
108+ return 0
109+ fi
110+
111+ # Properly iterate over the non-empty elements in the array
112+ echo "$urls" | while IFS= read -r url; do
105113 if [[ ! "$url" =~ ^https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?$ ]]; then
106114 echo "::error file=$metadata_file::'$field' contains an invalid URL: $url"
107115 ((errors++))
108116 fi
109117 done
110- else
111- if [[ ! "$value" =~ ^https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?$ ]]; then
112- echo "::error file=$metadata_file::'$field' is not a valid URL"
113- ((errors++))
114- fi
115118 fi
116119 }
117120
0 commit comments