Skip to content

Commit

Permalink
🎨 Retry push attempts
Browse files Browse the repository at this point in the history
Even with pull before push in place, rejections can occur.
With the retry, this chance should be minimized.
  • Loading branch information
scthi committed Oct 26, 2022
1 parent c5cc7a2 commit 3099677
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ runs:
working-directory: .github/${{ inputs.gitops-repository }}
shell: bash
run: |
push_to_gitops_repo () {
# In case there was another push in the meantime, we pull it again
git pull --rebase https://${{ inputs.gitops-user }}:${{ inputs.gitops-token }}@github.com/${{ inputs.gitops-organization }}/${{ inputs.gitops-repository }}.git
git push https://${{ inputs.gitops-user }}:${{ inputs.gitops-token }}@github.com/${{ inputs.gitops-organization }}/${{ inputs.gitops-repository }}.git
}
commit_changes () {
if [[ ${{ steps.preparation.outputs.push }} == "true" ]]; then
git add .
Expand All @@ -157,9 +163,9 @@ runs:
fi
git commit -m "Release ${{ inputs.docker-registry }}/${{ inputs.docker-image }}:${{ steps.preparation.outputs.tag }}"
# In case there was another push in the meantime, we pull it again
git pull --rebase https://${{ inputs.gitops-user }}:${{ inputs.gitops-token }}@github.com/${{ inputs.gitops-organization }}/${{ inputs.gitops-repository }}.git
git push https://${{ inputs.gitops-user }}:${{ inputs.gitops-token }}@github.com/${{ inputs.gitops-organization }}/${{ inputs.gitops-repository }}.git
# retry push attempt since rejections can still happen (even with pull before push)
push_to_gitops_repo || push_to_gitops_repo || push_to_gitops_repo
fi
}
Expand Down

0 comments on commit 3099677

Please sign in to comment.