fix(ci): retry gitops sync pushes
This commit is contained in:
parent
46a0758335
commit
d2e7aee81b
1 changed files with 19 additions and 9 deletions
28
.github/workflows/build-and-deploy-ghcr.yml
vendored
28
.github/workflows/build-and-deploy-ghcr.yml
vendored
|
|
@ -78,14 +78,24 @@ jobs:
|
|||
set -euo pipefail
|
||||
git clone "https://${{ secrets.GHCR_USERNAME }}:${GITOPS_TOKEN}@github.com/${GITOPS_REPO}.git" /tmp/nxtgauge-gitops
|
||||
cd /tmp/nxtgauge-gitops
|
||||
./scripts/set-backend-rust-release.sh "${{ matrix.service }}" "${{ steps.build.outputs.digest }}"
|
||||
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/nxtgauge-backend-rust/overlays/prod/backend-release-state.tsv apps/nxtgauge-backend-rust/overlays/prod/release-patches.yaml apps/nxtgauge-backend-rust/overlays/prod/disabled-deployments.yaml
|
||||
git commit -m "chore(gitops): deploy backend ${{ matrix.service }}@${{ github.sha }}"
|
||||
git pull --rebase origin main
|
||||
git push origin HEAD:main
|
||||
for attempt in 1 2 3 4 5; do
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
./scripts/set-backend-rust-release.sh "${{ matrix.service }}" "${{ steps.build.outputs.digest }}"
|
||||
if git diff --quiet; then
|
||||
echo "GitOps repo already up to date."
|
||||
exit 0
|
||||
fi
|
||||
git add apps/nxtgauge-backend-rust/overlays/prod/backend-release-state.tsv apps/nxtgauge-backend-rust/overlays/prod/release-patches.yaml apps/nxtgauge-backend-rust/overlays/prod/disabled-deployments.yaml
|
||||
git commit -m "chore(gitops): deploy backend ${{ matrix.service }}@${{ github.sha }}"
|
||||
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