Skip to content

Commit 486485c

Browse files
authored
Improve behavior of retries to add more information and customization (#71)
* Improve behavior of retries to add more information and customization * Add debug option * Update wait time between retries * Update release test * Remove debug and increase wait time
1 parent 2bf6459 commit 486485c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.circleci/test-deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ workflows:
6666
executor: ["docker-x86-debian", "apple-silicon-14", "apple-silicon-15", "linuxvm-arm-ubuntu-2004", "linuxvm-x86-ubuntu-2004", "linuxvm-arm-ubuntu-2204", "linuxvm-x86-ubuntu-2204", "linuxvm-arm-ubuntu-2404", "linuxvm-x86-ubuntu-2404"]
6767
version: [2.27.0, 2.40.0, "latest"] # 2.27.0 is the last version that uses ".tar.gz" instead of ".zip" for macOS
6868
- github-cli/release:
69-
tag: "test-release-$CIRCLE_SHA1"
69+
tag: "test-release"
7070
title: Test
7171
prerelease: true
7272
files: README.md
7373
context: orb-developer
7474
token: GHI_TOKEN
7575
additional_args: --generate-notes
76+
post-steps:
77+
- run: gh release delete test-release --cleanup-tag -y
7678
- orb-tools/pack:
7779
filters: *release-filters
7880
- orb-tools/publish:

src/commands/install.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ parameters:
1010
type: string
1111
default: "on_success"
1212
description: Specify when to run this command. Options are "on_success", "always" or "on_fail".
13+
max_retries:
14+
type: integer
15+
default: 5
16+
description: Max of retries to do when the request to github releases fails.
17+
1318
steps:
1419
- run:
1520
environment:
1621
PARAM_GH_CLI_VERSION: <<parameters.version>>
22+
PARAM_GH_MAX_RETRIES: <<parameters.max_retries>>
1723
name: Install GH CLI v<<parameters.version>>
1824
command: <<include(scripts/install.sh)>>
1925
when: <<parameters.when>>

src/scripts/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ download_gh_cli() {
3232
local platform=$1
3333
local file_extension=$2
3434
if [ "$PARAM_GH_CLI_VERSION" = "latest" ]; then
35-
max_retries=3
35+
max_retries=$PARAM_GH_MAX_RETRIES
3636
i=0
3737
while (( i < max_retries )); do
3838
((i++))
@@ -41,10 +41,10 @@ download_gh_cli() {
4141
break
4242
fi
4343
echo "Couldn't get latest version, retrying..."
44-
sleep 3
44+
sleep 60
4545
done
4646
if (( i == max_retries )); then
47-
echo "Erro: Max retries exceeded"
47+
echo "Error: Max retries exceeded."
4848
exit 1
4949
fi
5050

0 commit comments

Comments
 (0)