Retry push until successful (#208)

Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
This commit is contained in:
merwanehamadi
2023-07-27 21:08:31 -07:00
committed by GitHub
parent e10ea033bd
commit 86f73dab68

View File

@@ -228,10 +228,23 @@ jobs:
git commit -m "${commit_message}"
git stash
current_branch=${{ github.ref_name }}
git fetch origin $current_branch
git rebase origin/$current_branch
git push origin HEAD
poetry run python send_to_googledrive.py || echo "Failed to upload to Google Drive"
attempts=0
max_attempts=3
while [ $attempts -lt $max_attempts ]; do
git fetch origin $current_branch
git rebase origin/$current_branch
if git push origin HEAD; then
echo "Success!"
poetry run python send_to_googledrive.py || echo "Failed to upload to Google Drive"
exit 0
else
echo "Attempt $(($attempts + 1)) failed. Retrying..."
attempts=$(($attempts + 1))
fi
done
echo "Failed after $max_attempts attempts."
env:
GDRIVE_BASE64: ${{ secrets.GDRIVE_BASE64 }}
GITHUB_REF_NAME: ${{ github.ref_name }}