This commit is contained in:
lirtual 2024-12-22 16:07:46 +08:00
parent 30ab56f190
commit 8e892b2805

View File

@ -8,43 +8,45 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Sync fork
uses: tgymnich/fork-sync@v1.8.0
with:
token: ${{ secrets.FORK_SYNC_TOKEN }}
owner: pagefaultgames
base: main
head: main
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.FORK_SYNC_TOKEN }}
- name: Merge main branch
id: merge_main
- name: Sync with upstream
id: sync
continue-on-error: true
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git fetch origin main
if git merge origin/main --no-edit; then
echo "merge_status=success" >> $GITHUB_OUTPUT
# 添加上游仓库
git remote add upstream https://github.com/pagefaultgames/pokerogue.git
# 获取上游更新
git fetch upstream main
# 检查是否有更新需要同步
if git rev-list HEAD..upstream/main --count | grep -q "^0$"; then
echo "sync_status=uptodate" >> $GITHUB_OUTPUT
echo "仓库已是最新,无需同步"
else
echo "merge_status=failed" >> $GITHUB_OUTPUT
exit 1
# 合并上游更新
if git merge upstream/main --no-edit; then
echo "sync_status=success" >> $GITHUB_OUTPUT
git push
else
echo "sync_status=failed" >> $GITHUB_OUTPUT
exit 1
fi
fi
- name: Check merge status
if: steps.merge_main.outputs.merge_status == 'failed'
- name: Check sync status
if: steps.sync.outputs.sync_status == 'failed'
run: |
echo "合并 main 分支失败,请手动解决冲突"
echo "同步上游仓库失败,请手动解决冲突"
exit 1
- name: Push merged changes
if: steps.merge_main.outputs.merge_status == 'success'
run: |
git push
- name: Setup Node.js
uses: actions/setup-node@v3
with:
@ -106,7 +108,7 @@ jobs:
fi
- name: Commit and push if changed
if: steps.check_changes.outputs.changes == 'true' && steps.merge_main.outputs.merge_status == 'success'
if: steps.check_changes.outputs.changes == 'true' && steps.sync.outputs.sync_status == 'success'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"