From 86f73dab6856911d6b2164ad2a838c7ffae36300 Mon Sep 17 00:00:00 2001 From: merwanehamadi Date: Thu, 27 Jul 2023 21:08:31 -0700 Subject: [PATCH] Retry push until successful (#208) Signed-off-by: Merwane Hamadi --- .github/workflows/ci.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fde364f8..530bd62d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }}