Skip to content

Commit

Permalink
add curl check in get-version-matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Feb 7, 2025
1 parent 420fb40 commit 57cb096
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/get-version-matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@


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

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 comments on commit 57cb096

Please sign in to comment.