Update sync-branches.yml
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
This commit is contained in:
parent
b4ab70fef7
commit
f02a74b225
73
.github/workflows/sync-branches.yml
vendored
73
.github/workflows/sync-branches.yml
vendored
@ -2,9 +2,8 @@ name: Sync Branches
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
# 每天10点UTC(你可以根据需要调整时区)
|
- cron: '0 10 * * *' # 每天10点UTC
|
||||||
- cron: '0 10 * * *'
|
workflow_dispatch: # 允许手动触发
|
||||||
workflow_dispatch: # 允许手动启动工作流
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sync:
|
sync:
|
||||||
@ -14,71 +13,25 @@ jobs:
|
|||||||
- name: Checkout the main repository
|
- name: Checkout the main repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
fetch-depth: 0 # 保证完整克隆仓库,包括历史记录
|
||||||
token: ${{ secrets.GH_TOKEN }} # 显式传递 GH_TOKEN
|
token: ${{ secrets.GH_TOKEN }} # 显式传递 GH_TOKEN
|
||||||
|
|
||||||
- name: Setup Git
|
- name: Setup Git
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "GitHub Actions"
|
git config --global user.name "GitHub Actions"
|
||||||
git config --global user.email "github-actions@github.com"
|
git config --global user.email "github-actions@github.com"
|
||||||
# Existing remotes and branches
|
|
||||||
- name: Add remote for MoreTore/openpilot
|
|
||||||
run: |
|
|
||||||
git remote add moretore https://github.com/MoreTore/openpilot.git
|
|
||||||
git fetch moretore mazda-frogpilot
|
|
||||||
git fetch moretore mazda-frogpilot-0.9.6 # 同步 mazda-frogpilot-0.9.6 分支
|
|
||||||
- name: Add remote for FrogAi/FrogPilot
|
|
||||||
run: |
|
|
||||||
git remote add frogai https://github.com/FrogAi/FrogPilot.git
|
|
||||||
git fetch frogai
|
|
||||||
- name: Delete conflicting branch mazda-frogpilot if it exists
|
|
||||||
run: |
|
|
||||||
git branch -r | grep "origin/mazda-frogpilot" && git push origin --delete mazda-frogpilot || echo "No conflict with mazda-frogpilot"
|
|
||||||
- name: Create and push mazda-frogpilot branch
|
|
||||||
run: |
|
|
||||||
git checkout -b mazda-frogpilot moretore/mazda-frogpilot
|
|
||||||
git push origin mazda-frogpilot
|
|
||||||
- name: Delete conflicting branch mazda-frogpilot-0.9.6 if it exists
|
|
||||||
run: |
|
|
||||||
git branch -r | grep "origin/mazda-frogpilot-0.9.6" && git push origin --delete mazda-frogpilot-0.9.6 || echo "No conflict with mazda-frogpilot-0.9.6"
|
|
||||||
- name: Create and push mazda-frogpilot-0.9.6 branch
|
|
||||||
run: |
|
|
||||||
git checkout -b mazda-frogpilot-0.9.6 moretore/mazda-frogpilot-0.9.6
|
|
||||||
git push origin mazda-frogpilot-0.9.6
|
|
||||||
- name: Delete conflicting branch FrogPilot if it exists
|
|
||||||
run: |
|
|
||||||
git branch -r | grep "origin/FrogPilot" && git push origin --delete FrogPilot || echo "No conflict with FrogPilot"
|
|
||||||
- name: Force fetch and reset FrogPilot branch from remote
|
|
||||||
run: |
|
|
||||||
git fetch --all
|
|
||||||
git checkout --orphan FrogPilot
|
|
||||||
git reset --hard frogai/FrogPilot
|
|
||||||
git push origin FrogPilot --force
|
|
||||||
- name: Delete conflicting branch FrogPilot-Development if it exists
|
|
||||||
run: |
|
|
||||||
git branch -r | grep "origin/FrogPilot-Development" && git push origin --delete FrogPilot-Development || echo "No conflict with FrogPilot-Development"
|
|
||||||
- name: Force fetch and reset FrogPilot-Development branch from remote
|
|
||||||
run: |
|
|
||||||
git fetch --all
|
|
||||||
git checkout --orphan FrogPilot-Development
|
|
||||||
git reset --hard frogai/FrogPilot-Development
|
|
||||||
git push origin FrogPilot-Development --force
|
|
||||||
|
|
||||||
- name: Add remote for yysnet/carrotpilot
|
- name: Add remote for yysnet/carrotpilot
|
||||||
run: |
|
run: |
|
||||||
git remote add ajouatom https://github.com/yysnet/carrotpilot.git
|
git remote add carrotpilot https://github.com/yysnet/carrotpilot.git || echo "Remote already exists"
|
||||||
git fetch ajouatom v7-wip10
|
git fetch carrotpilot v7-wip10 --depth=1 # 只获取该分支的最新提交
|
||||||
- name: Sync v7-wip10 yysnet/carrotpilot
|
|
||||||
run: |
|
|
||||||
git branch -r | grep "origin/v7-wip10" && git push origin --delete v7-wip10 || echo "No conflict withv7-wip10 "
|
|
||||||
git checkout -b v7-wip10 yysnet/v7-wip10
|
|
||||||
git push origin v7-wip10
|
|
||||||
|
|
||||||
- name: Add remote for ajouatom/openpilot
|
- name: Sync v7-wip10 from carrotpilot
|
||||||
run: |
|
run: |
|
||||||
git remote add ajouatom https://github.com/ajouatom/openpilot.git
|
# 检查远程是否有 v7-wip10 分支
|
||||||
git fetch ajouatom v7-wip10-x-da
|
if git ls-remote --heads carrotpilot v7-wip10 | grep -q "refs/heads/v7-wip10"; then
|
||||||
- name: Sync v7-wip10-x-da ajouatom/openpilot
|
git checkout -B v7-wip10 carrotpilot/v7-wip10 # 强制切换到远程分支
|
||||||
run: |
|
git push origin v7-wip10 --force # 强制推送到自己的仓库
|
||||||
git branch -r | grep "origin/v7-wip10-x-da" && git push origin --delete v7-wip10-x-da || echo "No conflict withv7-wip10-x-da "
|
else
|
||||||
git checkout -b v7-wip10-x-da ajouatom/v7-wip10-x-da
|
echo "Branch v7-wip10 does not exist on carrotpilot, skipping..."
|
||||||
git push origin v7-wip10-x-da
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user