fix(ci): retry README auto-commit push on race (rebase + up to 5 attempts)
This commit is contained in:
parent
c5d9161e35
commit
22e7b5934e
1 changed files with 20 additions and 2 deletions
22
.github/workflows/update-readme.yml
vendored
22
.github/workflows/update-readme.yml
vendored
|
|
@ -45,5 +45,23 @@ jobs:
|
||||||
git config --global user.name 'github-actions[bot]'
|
git config --global user.name 'github-actions[bot]'
|
||||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||||
git add README*.md
|
git add README*.md
|
||||||
git diff --quiet && git diff --staged --quiet || git commit -m "docs: auto-update README [skip ci]"
|
# 没有变更就直接退出,别浪费 attempt 次数
|
||||||
git push
|
if git diff --quiet && git diff --staged --quiet; then
|
||||||
|
echo "No README changes to commit."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
git commit -m "docs: auto-update README [skip ci]"
|
||||||
|
|
||||||
|
# 推回 main 时处理 push race:并发 run 或人工 push 都可能抢先到 remote,
|
||||||
|
# 这里最多重试 5 次,每次失败就 rebase 到最新 main 再试。
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
if git push; then
|
||||||
|
echo "Pushed on attempt $i"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "Push rejected on attempt $i; rebasing onto latest main and retrying..."
|
||||||
|
git pull --rebase origin main
|
||||||
|
sleep $((i * 2))
|
||||||
|
done
|
||||||
|
echo "Push still failing after 5 attempts" >&2
|
||||||
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue