Skip to content

Commit 9870065

Browse files
committed
ci: Make auto-commit step resilient to concurrent pushes
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.
1 parent be67057 commit 9870065

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/update-readme.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,33 @@ jobs:
2020
template: "templates/README.md.tpl"
2121
writeTo: "profile/README.md"
2222

23-
- uses: stefanzweifel/git-auto-commit-action@v7.1.0
23+
- name: Commit changes
24+
id: auto-commit
2425
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
26+
uses: stefanzweifel/git-auto-commit-action@v7.1.0
2527
env:
2628
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2729
with:
2830
branch: main
2931
commit_message: "chore: Update generated README"
3032
commit_user_name: "GitHub Actions Bot"
3133
commit_user_email: "actions@github.com"
32-
commit_author: "GitHub Actions Bot <actions@github.com>"
34+
commit_author: "GitHub Actions Bot <actions@github.com>"
35+
skip_push: true
36+
37+
- name: Push changes with retry
38+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.auto-commit.outputs.changes_detected == 'true'
39+
run: |
40+
max_retries=3
41+
for attempt in $(seq 1 $max_retries); do
42+
echo "Push attempt $attempt of $max_retries"
43+
if git push origin main; then
44+
echo "Push succeeded on attempt $attempt"
45+
exit 0
46+
fi
47+
echo "Push failed, pulling with rebase and retrying..."
48+
git pull --rebase origin main
49+
sleep $((attempt * 2))
50+
done
51+
echo "Push failed after $max_retries attempts"
52+
exit 1

0 commit comments

Comments
 (0)