Skip to content

Commit fc0d0fe

Browse files
authored
Merge pull request #24 from EngineeringKiosk/andygrunwald/race-safe-auto-commit
ci: Make auto-commit step resilient to concurrent pushes
2 parents be67057 + 9870065 commit fc0d0fe

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)