Skip to content

Commit 653d631

Browse files
committed
Refactoring the execute_and_retry.sh
1 parent fc1c9a3 commit 653d631

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

.github/workflows/util/execute_and_retry.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
# This function is for retrying commands in the case they fail. It accepts three arguments
44
# $1: Number of retries it will attempt
55
# $2: Command to execute
6-
# $3: Clean up commands
6+
# $3: (Optional) Command for cleaning up resources if $2 fails
77
execute_and_retry () {
88
retry_counter=0
99
max_retry=$1
10+
command=$2
11+
cleanup=$3
1012
while [ $retry_counter -lt $max_retry ]; do
1113
attempt_failed=0
12-
eval "$2" || attempt_failed=$?
14+
eval "$command" || attempt_failed=$?
1315

1416
if [ $attempt_failed -ne 0 ]; then
15-
eval "$3"
17+
eval "$cleanup"
1618
retry_counter=$(($retry_counter+1))
1719
sleep 5
1820
else

0 commit comments

Comments
 (0)