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