fix(ci): retry gitops sync pushes

This commit is contained in:
Ashwin Kumar Sivakumar 2026-06-16 01:26:32 +05:30
parent 91d91481c8
commit d132f957b4

View file

@ -56,13 +56,24 @@ jobs:
image_ref="${IMAGE_NAME}@${{ steps.build.outputs.digest }}"
git clone "https://${{ secrets.GHCR_USERNAME }}:${GITOPS_TOKEN}@github.com/${GITOPS_REPO}.git" /tmp/nxtgauge-gitops
cd /tmp/nxtgauge-gitops
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
for attempt in 1 2 3 4 5; do
git fetch origin main
git reset --hard origin/main
./scripts/set-app-release.sh "$APP_KEY" "$image_ref"
if git diff --quiet; then
echo "GitOps repo already up to date."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add apps scripts/set-app-release.sh
git commit -m "chore(gitops): deploy ${APP_KEY}@${{ github.sha }}"
git push origin HEAD:main
if git push origin HEAD:main; then
exit 0
fi
echo "GitOps push race on attempt ${attempt}, retrying..."
git reset --hard origin/main
sleep $((attempt * 2))
done
echo "Failed to update GitOps after multiple attempts."
exit 1