File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Sync from Uni-CTR
2+
3+ on :
4+ schedule :
5+ - cron : ' 0 2 * * *' # 每天凌晨2点(UTC)
6+ workflow_dispatch : # 允许手动触发
7+
8+ jobs :
9+ sync_repo :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ # Step 1: 检出目标仓库
14+ - name : Checkout Destination Repo
15+ uses : actions/checkout@v3
16+ with :
17+ token : ${{ secrets.GITHUB_TOKEN }}
18+ fetch-depth : 0
19+
20+ # Step 2: 备份 .github 目录
21+ - name : Backup .github directory
22+ run : |
23+ mkdir -p /tmp/github_backup
24+ cp -r .github /tmp/github_backup
25+
26+ # Step 3: 添加源仓库为远程仓库
27+ - name : Add Source Repo as Remote
28+ run : |
29+ git remote add source https://github.com/archersama/Uni-CTR.git
30+ git fetch source
31+
32+ # Step 4: 同步源仓库内容到目标仓库
33+ - name : Sync from Source to Destination
34+ run : |
35+ git reset --hard source/main # 将目标仓库重置为源仓库的 main 分支内容
36+
37+ # Step 5: 恢复 .github 目录
38+ - name : Restore .github directory
39+ run : |
40+ cp -r /tmp/github_backup/.github .
41+
42+ # Step 6: 配置 git 用户信息
43+ - name : Set Git User Identity
44+ run : |
45+ git config --local user.name "FzKuji"
46+ git config --local user.email "[email protected] " 47+
48+ # Step 7: 强制推送到目标仓库
49+ - name : Push to Destination
50+ run : |
51+ git add .github
52+ git commit -m "Restore .github after sync"
53+ git push origin main --force
You can’t perform that action at this time.
0 commit comments