mirror of
https://gitee.com/houhuan/TrendRadar.git
synced 2025-12-21 12:47:16 +08:00
fix: 修复硬编码 main 分支导致的兼容性问题
This commit is contained in:
parent
c02e5cb55f
commit
648f8afd8e
15
.github/workflows/crawler.yml
vendored
15
.github/workflows/crawler.yml
vendored
@ -5,7 +5,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: crawler-main-branch
|
||||
group: crawler-${{ github.ref_name }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
@ -20,7 +20,6 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
clean: true
|
||||
|
||||
@ -69,18 +68,20 @@ jobs:
|
||||
run: python main.py
|
||||
|
||||
- name: Commit and push if changes
|
||||
env:
|
||||
BRANCH_NAME: ${{ github.event.repository.default_branch }}
|
||||
run: |
|
||||
git config --global user.name 'GitHub Actions'
|
||||
git config --global user.email 'actions@github.com'
|
||||
|
||||
echo "🔄 Syncing with remote..."
|
||||
git fetch origin main
|
||||
echo "🔄 Syncing with remote (branch: $BRANCH_NAME)..."
|
||||
git fetch origin $BRANCH_NAME
|
||||
|
||||
# 保存当前更改
|
||||
git stash --include-untracked || echo "Nothing to stash"
|
||||
|
||||
# 同步到远程最新
|
||||
git reset --hard origin/main
|
||||
git reset --hard origin/$BRANCH_NAME
|
||||
|
||||
# 恢复本次更改
|
||||
git stash pop || echo "Nothing to pop"
|
||||
@ -98,11 +99,11 @@ jobs:
|
||||
|
||||
echo "⬆️ Pushing changes with retry..."
|
||||
for i in {1..5}; do
|
||||
git pull --rebase origin main && git push origin main && {
|
||||
git pull --rebase origin $BRANCH_NAME && git push origin $BRANCH_NAME && {
|
||||
echo "✅ Successfully pushed on attempt $i"
|
||||
exit 0
|
||||
}
|
||||
echo "⚠️ Attempt $i/$i failed, waiting $((i*3)) seconds..."
|
||||
echo "⚠️ Attempt $i failed, waiting $((i*3)) seconds..."
|
||||
sleep $((i * 3))
|
||||
done
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user