From 98700653c583e315b27c33eaa73cda442432f7b4 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Sun, 3 May 2026 15:48:56 +0200 Subject: [PATCH] ci: Make auto-commit step resilient to concurrent pushes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stefanzweifel/git-auto-commit-action does not pull or rebase before pushing (this is a deliberate non-goal upstream). When this workflow runs concurrently with other actors pushing unrelated changes to main (e.g. a different folder), the action's internal git push is rejected as non-fast-forward and the workflow fails — even though the changes do not conflict. Switch to skip_push and add a small retry loop that does git pull --rebase between push attempts, mirroring the pattern already proven in the EngineeringKiosk/podcast-metadata workflows. --- .github/workflows/update-readme.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index bf407ab..8424e58 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -20,8 +20,10 @@ jobs: template: "templates/README.md.tpl" writeTo: "profile/README.md" - - uses: stefanzweifel/git-auto-commit-action@v7.1.0 + - name: Commit changes + id: auto-commit if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + uses: stefanzweifel/git-auto-commit-action@v7.1.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -29,4 +31,22 @@ jobs: commit_message: "chore: Update generated README" commit_user_name: "GitHub Actions Bot" commit_user_email: "actions@github.com" - commit_author: "GitHub Actions Bot " \ No newline at end of file + commit_author: "GitHub Actions Bot " + skip_push: true + + - name: Push changes with retry + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.auto-commit.outputs.changes_detected == 'true' + run: | + max_retries=3 + for attempt in $(seq 1 $max_retries); do + echo "Push attempt $attempt of $max_retries" + if git push origin main; then + echo "Push succeeded on attempt $attempt" + exit 0 + fi + echo "Push failed, pulling with rebase and retrying..." + git pull --rebase origin main + sleep $((attempt * 2)) + done + echo "Push failed after $max_retries attempts" + exit 1 \ No newline at end of file