Skip to content

Commit 57cb096

Browse files
committed
add curl check in get-version-matrix
1 parent 420fb40 commit 57cb096

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/get-version-matrix.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44

55

66
function get_latest_version() {
7-
curl -s https://api.github.com/repos/hashicorp/terraform/git/refs/tags | \
8-
jq ".[] | .ref | split(\"/\") | .[2] | select(. | startswith(\"$1\"))" | \
9-
sort -V -r | head -1
7+
if output=$(curl -s -f https://api.github.com/repos/hashicorp/terraform/git/refs/tags); then
8+
echo "$output" | \
9+
jq ".[] | .ref | split(\"/\") | .[2] | select(. | startswith(\"$1\"))" | \
10+
sort -V -r | head -1
11+
else
12+
echo "Error: Failed to connect to GitHub API" >&2
13+
return 1
14+
fi
1015
}
1116

1217
echo "matrix=[$(get_latest_version v1.0), $(get_latest_version v1.3), $(get_latest_version v1.5), $(get_latest_version v1.7), $(get_latest_version v1.9)]" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)