From 5d73ec7626bcffa74fb124c577507231d1985d78 Mon Sep 17 00:00:00 2001 From: Yash Kalwani Date: Wed, 30 Sep 2026 11:30:34 -0400 Subject: [PATCH] fix: rebase onto latest and retry push with jitter on non-fast-forward Parallel preview destroy/deploy jobs race on the deploy repo's main branch; a fixed 10s whole-step retry made colliding jobs retry in lockstep and lose. Retry the push in place: pull --rebase, jittered sleep, up to 6 tries. Raise default commit-timeout 60 -> 180s to fit the inner loop. --- action.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d02cf65..8076348 100644 --- a/action.yml +++ b/action.yml @@ -93,7 +93,7 @@ inputs: commit-timeout: description: 'Commit timeout (in seconds)' required: false - default: "60" + default: "180" helm-dependency-build: description: 'Run helm dependency build, only for helm toolchain, `true` or `false`' required: false @@ -442,7 +442,19 @@ runs: git add -A git status git diff-index --quiet HEAD || git commit -m "Deploy ${{ github.repository }} SHA ${{ github.sha }} RUN ${{ github.run_id }} ATEMPT ${{ github.run_attempt }}" - git push origin ${{ steps.destination.outputs.ref }} + # Many jobs (one per app, across PRs) push to the same branch at once. If the push is + # rejected, fetch and rebase onto the latest remote and push again, with random jitter + # so competing jobs do not retry in lockstep. Paths are disjoint, so the rebase is clean. + REF='${{ steps.destination.outputs.ref }}' + for i in 1 2 3 4 5 6; do + git push origin "${REF}" && break + if [ "${i}" -eq 6 ]; then + echo "::error::push to ${REF} rejected after ${i} attempts" + exit 1 + fi + sleep $(( (RANDOM % 8) + i )) + git pull --rebase origin "${REF}" + done echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT