Update sync-upstream.yml

This commit is contained in:
tidex 2025-02-15 22:54:42 +08:00 committed by GitHub
parent 3ab61e6fae
commit 94ce06acd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 20 deletions

View File

@ -2,39 +2,39 @@ name: Sync Upstream and Trigger Build
on:
schedule:
- cron: "0 0 * * *" # 每天 UTC 时间 0 点自动同步
- cron: "0 0 * * *" # 每天 UTC 时间 0 点检查一次
workflow_dispatch: # 支持手动触发
jobs:
sync-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Fork
- name: Checkout Fork 代码
uses: actions/checkout@v4
with:
fetch-depth: 0 # 必须获取完整提交历史
token: ${{ secrets.TOKEN }} # 使用具有写入权限的token
fetch-depth: 0 # 获取完整 Git 历史
- name: 添加上游仓库
- name: 添加上游仓库 Remote
run: |
git remote add upstream https://github.com/cloudflare/cloudflared.git
- name: 获取上游更新
run: git fetch upstream
- name: 合并代码
- name: 获取上游最新代码
run: |
# 尝试自动合并,失败时创建合并提交
git merge --no-edit upstream/master || \
git merge --no-edit --allow-unrelated-histories upstream/master
git fetch upstream
- name: 推送更新
run: git push origin main
- name: 合并上游代码到本地分支
run: |
git merge upstream/master --no-edit # 假设上游主分支是 master
# 如果有冲突,这里会失败(需手动处理)
- name: 触发构建
uses: actions/trigger-workflow@v1.0.0
- name: 推送更新到 Fork 仓库
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
run: |
git push origin master
- name: 触发编译工作流
uses: benc-uk/workflow-dispatch@v1
with:
repo: ${{ github.repository }} # 当前仓库
github_token: ${{ secrets.TOKEN }}
workflow_file: build.yml # 目标工作流文件
wait_for_completion: false
workflow: build.yml # 你的编译工作流文件名
token: ${{ secrets.TOKEN }}