From 648f8afd8e28d56f59967cf0a998a44a6f786592 Mon Sep 17 00:00:00 2001 From: sansan <77180927+sansan0@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:10:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A1=AC=E7=BC=96?= =?UTF-8?q?=E7=A0=81=20main=20=E5=88=86=E6=94=AF=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/crawler.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/crawler.yml b/.github/workflows/crawler.yml index 3d9a3a5..6d44bb0 100644 --- a/.github/workflows/crawler.yml +++ b/.github/workflows/crawler.yml @@ -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