Skip to content

Commit 0c512fa

Browse files
committed
Retry snap install command if failed
1 parent 20b97d2 commit 0c512fa

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.github/workflows/workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: sudo apt-get update && sudo apt-get install snapd sqlite3
2626

2727
- name: Install newsboat
28-
run: sudo snap install newsboat
28+
run: source ./scripts/retry.sh && with_retry 5 sudo snap install newsboat
2929

3030
- name: Fetch liveboat
3131
run: |

scripts/retry.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
with_retry() {
4+
local -r -i max_attempts="$1"; shift
5+
local -i attempt_num=1
6+
until "$@"
7+
do
8+
if ((attempt_num==max_attempts))
9+
then
10+
echo "Attempt $attempt_num failed and there are no more attempts left!"
11+
return 1
12+
else
13+
echo "Attempt $attempt_num failed! Trying again in $attempt_num seconds..."
14+
sleep $((attempt_num++))
15+
fi
16+
done
17+
}

0 commit comments

Comments
 (0)