Merge pull request #2 from Bill-Billion/chore/sync-fork-workflow

ci: 定时把 fork main 同步到上游 shareAI-lab/main
This commit is contained in:
Yang Haoran 2026-06-25 18:15:54 +08:00 committed by GitHub
commit 5ca7c151ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

33
.github/workflows/sync-upstream.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: Sync fork with upstream
# 定时把本 fork 的 main 合入上游 shareAI-lab/learn-claude-code 的最新提交。
# 因为这个 workflow 文件本身就在 main 上,main 与上游已分叉、无法 fast-forward,
# 所以用 merge 而非 gh repo sync。结果:main = 全部上游更新 + 本自动化提交。
# 自己的改动请始终开新分支,不要直接提交到 main,否则可能与上游产生合并冲突。
on:
schedule:
- cron: '0 * * * *' # 每小时一次;想每天一次改成 '0 6 * * *'
workflow_dispatch: # 也可在仓库 Actions 页面手动触发
permissions:
contents: write # 合并后需要写权限 push 回 main
jobs:
sync:
runs-on: ubuntu-latest
steps:
# actions/checkout@v6 —— 与本仓库其它 workflow 用同一 pin
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: main
fetch-depth: 0 # merge 需要完整历史
- name: Merge upstream/main into main
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote add upstream https://github.com/shareAI-lab/learn-claude-code.git
git fetch upstream main
git merge --no-edit upstream/main
git push origin main