fix(ci): retry gitops sync pushes
This commit is contained in:
parent
91d91481c8
commit
d132f957b4
1 changed files with 19 additions and 8 deletions
17
.github/workflows/build-and-deploy-ghcr.yml
vendored
17
.github/workflows/build-and-deploy-ghcr.yml
vendored
|
|
@ -56,13 +56,24 @@ jobs:
|
||||||
image_ref="${IMAGE_NAME}@${{ steps.build.outputs.digest }}"
|
image_ref="${IMAGE_NAME}@${{ steps.build.outputs.digest }}"
|
||||||
git clone "https://${{ secrets.GHCR_USERNAME }}:${GITOPS_TOKEN}@github.com/${GITOPS_REPO}.git" /tmp/nxtgauge-gitops
|
git clone "https://${{ secrets.GHCR_USERNAME }}:${GITOPS_TOKEN}@github.com/${GITOPS_REPO}.git" /tmp/nxtgauge-gitops
|
||||||
cd /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"
|
./scripts/set-app-release.sh "$APP_KEY" "$image_ref"
|
||||||
if git diff --quiet; then
|
if git diff --quiet; then
|
||||||
echo "GitOps repo already up to date."
|
echo "GitOps repo already up to date."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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 add apps scripts/set-app-release.sh
|
||||||
git commit -m "chore(gitops): deploy ${APP_KEY}@${{ github.sha }}"
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue