Skip to content

Commit

Permalink
Create a retry.sh script to execute comands for main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
FredMagas committed Aug 8, 2024
1 parent 8bb3984 commit 6584753
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }}
run: |
source venv/bin/activate
python manage.py makemigrations
python manage.py migrate
./retry.sh
- name: Trigger Render Deploy
env:
Expand Down
23 changes: 23 additions & 0 deletions retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

retry() {
local n=1
local max=5
local delay=5
while true; do
"$@" && break || {
if [[ $n -lt $max ]]; then
((n++))
echo "Command failed. Attempt $n/$max:"
sleep $delay;
else
echo "The command has failed after $n attempts."
return 1
fi
}
done
}

echo "Running migrations with retries..."
retry python manage.py makemigrations
retry python manage.py migrate

0 comments on commit 6584753

Please sign in to comment.