Skip to content

欢迎来到电子书下载宝库,一个汇聚了各类电子书下载链接的地方。无论你是喜欢阅读经典文学、经管励志、终身学习、职场创业、技术手册还是其他类型的书籍,这里都能满足你的需求。 该库涵盖了帆书app(原樊登读书)、微信读书、京东读书、喜马拉雅等读书app的大部分电子书。

Python

fix: 修复 GitHub Actions Git push 冲突问题

jbiaojerry93cf3ffcf5a2
diff --git a/.github/workflows/full-sync.yml b/.github/workflows/full-sync.yml
index 63b917d..0d652aa 100644
--- a/.github/workflows/full-sync.yml
+++ b/.github/workflows/full-sync.yml
@@ -19,6 +19,7 @@ jobs:
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
+ fetch-depth: 0 # 获取完整历史,避免推送冲突
- name: Set up Python
uses: actions/setup-python@v5
@@ -60,7 +61,33 @@ jobs:
# 添加所有变更(md目录、README.md、all_books.json等)
git add md/ README.md docs/all-books.json docs/parse-stats.json || true
git commit -m "auto: full sync books and update README [skip ci]" || echo "No changes to commit"
- git push
+
+ # 在推送前先拉取远程更改(避免推送冲突)
+ echo "📥 拉取远程最新更改..."
+ git fetch origin main
+ git pull origin main --rebase || git pull origin main --no-rebase || true
+
+ # 推送更改(最多重试3次)
+ max_retries=3
+ retry_count=0
+ while [ $retry_count -lt $max_retries ]; do
+ if git push origin main; then
+ echo "✅ 推送成功"
+ break
+ else
+ retry_count=$((retry_count + 1))
+ echo "⚠️ 推送失败,重试 $retry_count/$max_retries..."
+ if [ $retry_count -lt $max_retries ]; then
+ # 重新拉取并合并
+ git fetch origin main
+ git rebase origin/main || git merge origin/main || true
+ sleep 2
+ else
+ echo "❌ 推送失败,已达到最大重试次数"
+ exit 1
+ fi
+ fi
+ done
else
echo "No changes to commit"
fi
diff --git a/.github/workflows/generate-site.yml b/.github/workflows/generate-site.yml
index fa2b2c6..b12518e 100644
--- a/.github/workflows/generate-site.yml
+++ b/.github/workflows/generate-site.yml
@@ -19,6 +19,8 @@ jobs:
steps:
- uses: actions/checkout@v4
+ with:
+ fetch-depth: 0 # 获取完整历史,避免推送冲突
- uses: actions/setup-python@v5
with:
@@ -50,4 +52,30 @@ jobs:
git add docs/index.html docs/books.json docs/all-books.json docs/parse-stats.json docs/search.js
git rm docs/index.md 2>/dev/null || true
git commit -m "auto: update index and search data" || echo "No changes"
- git push
+
+ # 在推送前先拉取远程更改(避免推送冲突)
+ echo "📥 拉取远程最新更改..."
+ git fetch origin main
+ git pull origin main --rebase || git pull origin main --no-rebase || true
+
+ # 推送更改(最多重试3次)
+ max_retries=3
+ retry_count=0
+ while [ $retry_count -lt $max_retries ]; do
+ if git push origin main; then
+ echo "✅ 推送成功"
+ break
+ else
+ retry_count=$((retry_count + 1))
+ echo "⚠️ 推送失败,重试 $retry_count/$max_retries..."
+ if [ $retry_count -lt $max_retries ]; then
+ # 重新拉取并合并
+ git fetch origin main
+ git rebase origin/main || git merge origin/main || true
+ sleep 2
+ else
+ echo "❌ 推送失败,已达到最大重试次数"
+ exit 1
+ fi
+ fi
+ done