cloudflared-mirror/.github/workflows/sync-upstream.yml

41 lines
1.2 KiB
YAML

name: Sync Upstream and Trigger Build
on:
schedule:
- cron: "0 0 * * *" # 每天 UTC 时间 0 点自动同步
workflow_dispatch: # 支持手动触发
jobs:
sync-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Fork
uses: actions/checkout@v4
with:
fetch-depth: 0 # 必须获取完整提交历史
token: ${{ secrets.TOKEN }} # 使用具有写入权限的token
- name: 添加上游仓库
run: |
git remote add upstream https://github.com/cloudflare/cloudflared.git
- name: 获取上游更新
run: git fetch upstream
- name: 合并代码
run: |
# 尝试自动合并,失败时创建合并提交
git merge --no-edit upstream/master || \
git merge --no-edit --allow-unrelated-histories upstream/master
- name: 推送更新
run: git push origin main
- name: 触发构建
uses: actions/trigger-workflow@v1.0.0
with:
repo: ${{ github.repository }} # 当前仓库
github_token: ${{ secrets.TOKEN }}
workflow_file: build.yml # 目标工作流文件
wait_for_completion: false