Update sync-upstream.yml

This commit is contained in:
tidex 2025-02-15 22:36:18 +08:00 committed by GitHub
parent 7f4edbe09b
commit 3ab61e6fae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 19 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 # 获取完整 Git 历史 fetch-depth: 0 # 必须获取完整提交历史
token: ${{ secrets.TOKEN }} # 使用具有写入权限的token
- name: 添加上游仓库 Remote - name: 添加上游仓库
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: | run: git fetch upstream
git fetch upstream
- name: 合并上游代码到本地分支 - name: 合并代码
run: | run: |
git merge upstream/master --no-edit # 假设上游主分支是 master # 尝试自动合并,失败时创建合并提交
# 如果有冲突,这里会失败(需手动处理) git merge --no-edit upstream/master || \
git merge --no-edit --allow-unrelated-histories upstream/master
- name: 推送更新到 Fork 仓库 - name: 推送更新
env: run: git push origin main
GITHUB_TOKEN: ${{ secrets.TOKEN }}
run: |
git push origin master
- name: 触发编译工作流 - name: 触发构建
uses: benc-uk/workflow-dispatch@v1 uses: actions/trigger-workflow@v1.0.0
with: with:
workflow: build.yml # 你的编译工作流文件名 repo: ${{ github.repository }} # 当前仓库
token: ${{ secrets.TOKEN }} github_token: ${{ secrets.TOKEN }}
workflow_file: build.yml # 目标工作流文件
wait_for_completion: false