Skip to content

Commit a2323c2

Browse files
committed
chore: version extraction
1 parent a935b19 commit a2323c2

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/dockerhub-release-matrix.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,17 @@ jobs:
109109
tags_array="["
110110
first=true
111111
112-
# Extract versions directly from matrix config using grep/sed
112+
# Extract versions using grep and sed
113113
matrix_json='${{ needs.prepare.outputs.matrix_config }}'
114-
versions=$(echo "$matrix_json" | grep -o '"version":"[^"]*"' | sed 's/"version":"\(.*\)"/\1/')
114+
versions=$(echo "$matrix_json" | grep -o '"version":"[^"]*"' | sed 's/.*:"//;s/"//')
115115
116116
# For each version
117117
while read -r version; do
118+
# Skip empty versions
119+
if [ -z "$version" ]; then
120+
continue
121+
fi
122+
118123
if [ "$first" = true ]; then
119124
first=false
120125
else
@@ -128,15 +133,25 @@ jobs:
128133
else
129134
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'$version'"]' ansible/vars.yml)
130135
fi
131-
PG_VERSION=$(echo $PG_VERSION | tr -d '"')
132136
133-
versions_array+="\"${version}\""
134-
tags_array+="\"supabase/postgres:${PG_VERSION}\""
137+
# Ensure PG_VERSION is not empty and remove quotes
138+
if [ -n "$PG_VERSION" ]; then
139+
PG_VERSION=$(echo $PG_VERSION | tr -d '"')
140+
141+
versions_array+="\"${version}\""
142+
tags_array+="\"supabase/postgres:${PG_VERSION}\""
143+
fi
135144
done <<< "$versions"
136145
137146
versions_array+="]"
138147
tags_array+="]"
139148
149+
# Validate arrays are not empty
150+
if [ "$versions_array" = "[]" ] || [ "$tags_array" = "[]" ]; then
151+
echo "Error: No valid versions found"
152+
exit 1
153+
fi
154+
140155
echo "versions=$versions_array" >> $GITHUB_OUTPUT
141156
echo "image_tags=$tags_array" >> $GITHUB_OUTPUT
142157

0 commit comments

Comments
 (0)