Skip to content

Commit 4d584ce

Browse files
committed
fix: Implement retry logic for git push to handle race conditions
1 parent 11f67da commit 4d584ce

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/update-manifest.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,18 @@ jobs:
8484
git commit -m "chore(${SERVICE_NAME}): update image to ${{ steps.info.outputs.branch }}-${{ steps.info.outputs.sha }}" \
8585
-m "Triggered by: ${{ github.event.workflow_run.html_url }}"
8686
87-
git push origin ${{ steps.info.outputs.branch }}
87+
# Retry loop for race conditions
88+
MAX_RETRIES=5
89+
for ((i=1; i<=MAX_RETRIES; i++)); do
90+
echo "🔄 Attempt $i of $MAX_RETRIES to push changes..."
91+
git pull --rebase origin ${{ steps.info.outputs.branch }}
92+
if git push origin ${{ steps.info.outputs.branch }}; then
93+
echo "✅ Push successful!"
94+
exit 0
95+
fi
96+
echo "⚠️ Push failed, retrying in roughly 5 seconds..."
97+
sleep $((RANDOM % 5 + 3))
98+
done
99+
100+
echo "❌ Failed to push changes after $MAX_RETRIES attempts."
101+
exit 1

0 commit comments

Comments
 (0)