Skip to content

Commit 7d77d26

Browse files
committed
test
1 parent 148f9b6 commit 7d77d26

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

.github/workflows/validate-new-plugin-metadata.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
echo "::group::Validating $metadata_file"
6666
6767
metadata=$(yq '.' "$metadata_file")
68+
echo "Metadata: $metadata"
6869
errors=0
6970
7071
# Function to check if a required field is missing
@@ -94,19 +95,25 @@ jobs:
9495
9596
# Handle arrays of URLs (e.g., screenshots)
9697
# 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
98+
local field_type=$(echo "$metadata" | yq -r ".${field} | type")
99+
local non_empty_value=0
100+
101+
if [[ "$field_type" == "!!seq" ]]; then
102+
for url in $(echo "$metadata" | yq ".$field | .[]"); do
103+
if [[ -z "$url" ]]; then
103104
continue
104105
fi
105106
if [[ ! "$url" =~ ^https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?$ ]]; then
106107
echo "::error file=$metadata_file::'$field' contains an invalid URL: $url"
107108
((errors++))
109+
else
110+
((non_empty_value++))
108111
fi
109112
done
113+
if [[ $non_empty_value -eq 0 && "$required" == "required" ]]; then
114+
echo "::error file=$metadata_file::'$field' is required but missing"
115+
((errors++))
116+
fi
110117
else
111118
if [[ ! "$value" =~ ^https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?$ ]]; then
112119
echo "::error file=$metadata_file::'$field' is not a valid URL"
@@ -122,18 +129,19 @@ jobs:
122129
check_required_field "detailed_description"
123130
124131
# Validate URLs (optional fields but must be valid if provided, add "required" as second parameter to make them required, ie: check_valid_url "community_url" "required")
125-
check_valid_url "community_url"
126132
check_valid_url "logo_url"
127133
check_valid_url "plugin_logo_url"
128134
check_valid_url "demo_video_url"
129135
check_valid_url "documentation_url"
130136
check_valid_url "changelog_url"
137+
check_valid_url "community_url"
131138
check_valid_url "screenshots"
132139
140+
echo "Metadata: $metadata"
133141
# Validate date format (YYYY-MM)
134142
release_date=$(echo "$metadata" | yq '.release_date')
135143
if [[ -z "$release_date" ]]; then
136-
echo "::error file=$metadata_file::'$release_date' is required but missing"
144+
echo "::error file=$metadata_file::'release_date' is required but missing"
137145
((errors++))
138146
else
139147
if [[ ! "$release_date" =~ ^202[0-9]{1}-[0-9]{2}$ ]]; then
@@ -143,9 +151,10 @@ jobs:
143151
fi
144152
145153
# Validate X account handle format (@username)
154+
echo "The X account handle is: $(echo "$metadata" | yq '.x_account_handle')"
146155
x_account_handle=$(echo "$metadata" | yq '.x_account_handle')
147156
if [[ -z "$x_account_handle" ]]; then
148-
echo "::error file=$metadata_file::'$x_account_handle' is required but missing"
157+
echo "::error file=$metadata_file::'x_account_handle' is required but missing"
149158
((errors++))
150159
else
151160
if [[ -n "$x_account_handle" && ! "$x_account_handle" =~ ^@[a-zA-Z0-9_]{1,15}$ ]]; then
@@ -155,9 +164,10 @@ jobs:
155164
fi
156165
157166
# Validate support contact (must be a valid URL or email)
167+
echo "The support contact is: $(echo "$metadata" | yq '.support_contact')"
158168
support_contact=$(echo "$metadata" | yq '.support_contact')
159169
if [[ -z "$support_contact" ]]; then
160-
echo "::error file=$metadata_file::'$support_contact' is required but missing"
170+
echo "::error file=$metadata_file::'support_contact' is required but missing"
161171
((errors++))
162172
else
163173
if [[ ! "$support_contact" =~ ^(https?:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+(:[0-9]{1,5})?(\/.*)?|[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$ ]]; then

0 commit comments

Comments
 (0)