-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (52 loc) · 2.34 KB
/
Copy pathsync-kernelsu.yml
File metadata and controls
60 lines (52 loc) · 2.34 KB
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
54
55
56
57
58
59
60
name: 同步到 KernelSU 仓库
# 触发条件:main 推送(镜像源码)、发布 Release(镜像发布)、手动
on:
push:
branches:
- main
release:
types: [published]
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: 拉取代码
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: 同步源码与标签
env:
DEST_REPO: "https://x-access-token:${{ secrets.SYNC_PAT }}@github.com/KernelSU-Modules-Repo/netproxy.git"
run: |
git remote add downstream "$DEST_REPO"
git push downstream --all --force
git push downstream --tags || true
echo "源代码推送完成!已跳过受保护的标签。"
- name: 同步最新 Release
# 仅在发布新 Release 或手动触发时运行
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.SYNC_PAT }}
UPSTREAM_REPO: ${{ github.repository }} # 当前仓库
DEST_REPO: "KernelSU-Modules-Repo/netproxy" # 目标仓库
run: |
# 1. 获取主仓库最新 Release 的标签名
LATEST_TAG=$(gh release view --repo "$UPSTREAM_REPO" --json tagName -q .tagName)
echo "主仓库最新 Release 标签: $LATEST_TAG"
# 2. 下游已存在该 Release 则跳过
if gh release view "$LATEST_TAG" --repo "$DEST_REPO" &>/dev/null; then
echo "下游仓库已存在 Release $LATEST_TAG,无需重复同步。"
else
echo "下游仓库缺失 Release $LATEST_TAG,开始同步..."
# 3. 下载主仓库的所有附件
mkdir -p release_assets
gh release download "$LATEST_TAG" --repo "$UPSTREAM_REPO" --dir release_assets
# 4. 获取主仓库 Release 的标题与更新日志
TITLE=$(gh release view "$LATEST_TAG" --repo "$UPSTREAM_REPO" --json name -q .name)
NOTES=$(gh release view "$LATEST_TAG" --repo "$UPSTREAM_REPO" --json body -q .body)
# 5. 在下游仓库创建相同 Release 并上传附件
gh release create "$LATEST_TAG" ./release_assets/* --repo "$DEST_REPO" --title "$TITLE" --notes "$NOTES"
echo "Release $LATEST_TAG 同步成功!"
fi