From de543eca4b3ac17a6c2498f91feeb81d2f299e6f Mon Sep 17 00:00:00 2001 From: Loki Date: Sun, 10 May 2026 18:11:55 +0800 Subject: [PATCH] fix sync.yml --- .github/workflows/sync.yml | 41 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index a7210fd4..a647cf30 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -15,25 +15,34 @@ jobs: if: ${{ github.event.repository.fork }} steps: - # Step 1: run a standard checkout action - name: Checkout target repo uses: actions/checkout@v4 + with: + fetch-depth: 0 - # Step 2: run the sync action - name: Sync upstream changes - id: sync - uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 - with: - upstream_sync_repo: apache/hugegraph-ai - upstream_sync_branch: main - target_sync_branch: main - target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" - # Set test_mode true to run tests instead of the true action!! - test_mode: false + git remote get-url upstream 2>/dev/null || git remote add upstream https://github.com/apache/hugegraph-ai.git + git fetch upstream main - - name: Sync check - if: failure() - run: | - echo "[Error] Due to a change in the workflow file of the upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the detailed tutorial for instructions: https://github.com/Yidadaa/ChatGPT-Next-Web#enable-automatic-updates" - exit 1 + # Check if upstream changed workflow files + WORKFLOW_CHANGED=$(git diff --name-only HEAD upstream/main -- .github/workflows/ | wc -l) + + LOCAL_HEAD=$(git rev-parse HEAD) + + # Merge all upstream changes + git merge upstream/main --no-edit + + # If upstream touched workflows, restore our local versions so + # GITHUB_TOKEN can push (it is blocked from updating .github/workflows) + if [ "$WORKFLOW_CHANGED" -gt 0 ]; then + echo "Upstream changed workflow files. Preserving local versions..." + git checkout "$LOCAL_HEAD" -- .github/workflows/ + git add .github/workflows/ + git diff --cached --quiet || git commit -m "sync: preserve local workflow files" + fi + + git push origin main