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