Skip to content

Commit 2bf6459

Browse files
authored
Feat/retries latest version (#69)
* Add logic to retry fetch of latest version * Update comparison for linter
1 parent 3c30640 commit 2bf6459

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/scripts/install.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,22 @@ download_gh_cli() {
3232
local platform=$1
3333
local file_extension=$2
3434
if [ "$PARAM_GH_CLI_VERSION" = "latest" ]; then
35-
LATEST_TAG=$(curl url -s https://api.github.com/repos/cli/cli/releases/latest | jq -r '.tag_name')
35+
max_retries=3
36+
i=0
37+
while (( i < max_retries )); do
38+
((i++))
39+
LATEST_TAG=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | jq -r '.tag_name')
40+
if [ "$LATEST_TAG" != null ]; then
41+
break
42+
fi
43+
echo "Couldn't get latest version, retrying..."
44+
sleep 3
45+
done
46+
if (( i == max_retries )); then
47+
echo "Erro: Max retries exceeded"
48+
exit 1
49+
fi
50+
3651
PARAM_GH_CLI_VERSION="${LATEST_TAG#v}"
3752
fi
3853
local download_url="https://github.com/cli/cli/releases/download/v${PARAM_GH_CLI_VERSION}/gh_${PARAM_GH_CLI_VERSION}_${platform}.${file_extension}"

0 commit comments

Comments
 (0)