42 lines
1.3 KiB
YAML
42 lines
1.3 KiB
YAML
name: Sync Branch
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 10 * * *' # 每天 UTC 10 点运行
|
|
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 }} # 访问 GitHub 需要的令牌
|
|
|
|
- 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
|
|
git fetch carrotpilot +refs/heads/v7-wip10:refs/remotes/carrotpilot/v7-wip10
|
|
|
|
- name: Ensure local branch matches remote
|
|
run: |
|
|
# 检查本地是否已有 v7-wip10 分支,如果有则删除
|
|
if git show-ref --verify --quiet refs/heads/v7-wip10; then
|
|
git branch -D v7-wip10
|
|
fi
|
|
|
|
# 创建本地 v7-wip10 分支并跟踪远程分支
|
|
git checkout -B v7-wip10 carrotpilot/v7-wip10
|
|
|
|
- name: Push to origin repository
|
|
run: |
|
|
git push origin v7-wip10 --force
|