diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 68476fa0..a2f0f71c 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -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 # 获取完整 Git 历史 + fetch-depth: 0 # 必须获取完整提交历史 + token: ${{ secrets.TOKEN }} # 使用具有写入权限的token - - name: 添加上游仓库 Remote + - name: 添加上游仓库 run: | git remote add upstream https://github.com/cloudflare/cloudflared.git - - name: 获取上游最新代码 - run: | - git fetch upstream + - name: 获取上游更新 + run: git fetch upstream - - name: 合并上游代码到本地分支 + - name: 合并代码 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 仓库 - env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} - run: | - git push origin master + - name: 推送更新 + run: git push origin main - - name: 触发编译工作流 - uses: benc-uk/workflow-dispatch@v1 + - name: 触发构建 + uses: actions/trigger-workflow@v1.0.0 with: - workflow: build.yml # 你的编译工作流文件名 - token: ${{ secrets.TOKEN }} + repo: ${{ github.repository }} # 当前仓库 + github_token: ${{ secrets.TOKEN }} + workflow_file: build.yml # 目标工作流文件 + wait_for_completion: false