Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading