name: Sync Branches on: schedule: - cron: '0 10 * * *' # 每天10点UTC workflow_dispatch: # 允许手动触发 jobs: sync: runs-on: ubuntu-latest steps: - name: Checkout the main repository uses: actions/checkout@v3 with: fetch-depth: 0 # 保证完整克隆仓库,包括历史记录 token: ${{ secrets.GH_TOKEN }} # 显式传递 GH_TOKEN - name: Setup Git run: | git config --global user.name "GitHub Actions" git config --global user.email "github-actions@github.com" - name: Add remote for yysnet/carrotpilot run: | git remote add carrotpilot https://github.com/yysnet/carrotpilot.git || echo "Remote already exists" git fetch carrotpilot v7-wip10 --depth=1 # 只获取该分支的最新提交 - name: Sync v7-wip10 from carrotpilot run: | # 检查远程是否有 v7-wip10 分支 if git ls-remote --heads carrotpilot v7-wip10 | grep -q "refs/heads/v7-wip10"; then git checkout -B v7-wip10 carrotpilot/v7-wip10 # 强制切换到远程分支 git push origin v7-wip10 --force # 强制推送到自己的仓库 else echo "Branch v7-wip10 does not exist on carrotpilot, skipping..." fi