-
Notifications
You must be signed in to change notification settings - Fork 175
72 lines (59 loc) · 1.79 KB
/
Copy pathbuild-release.yml
File metadata and controls
72 lines (59 loc) · 1.79 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
61
62
63
64
65
66
67
68
69
70
71
72
name: Sync Open Source Mirror
permissions:
contents: write
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
jobs:
sync-opensource:
runs-on: ubuntu-latest
steps:
- name: Checkout Private Repo
uses: actions/checkout@v4
with:
path: private-repo
- name: Checkout Public Repo
uses: actions/checkout@v4
with:
repository: Jamailar/RedBox
token: ${{ secrets.PUBLIC_REPO_TOKEN }}
path: public-repo
- name: Sync Files
run: |
set -euo pipefail
sync_dir() {
local src="$1"
local dst="$2"
if [ -d "$src" ]; then
mkdir -p "$dst"
rsync -av --delete "$src"/ "$dst"/
else
echo "Source missing: $src, removing target: $dst"
rm -rf "$dst"
fi
}
# 仅同步代码与 README(以及 README 依赖图片)
cp private-repo/README.md public-repo/
cp private-repo/LICENSE public-repo/
sync_dir private-repo/desktop public-repo/desktop
sync_dir private-repo/scripts public-repo/scripts
sync_dir private-repo/images public-repo/images
# Plugin 不开源:强制移除
rm -rf public-repo/Plugin
- name: Commit and Push to Public Repo
run: |
set -euo pipefail
cd public-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --staged --quiet; then
echo "No changes to sync"
exit 0
fi
git commit -m "chore: sync open-source mirror from ${{ github.ref_name }}"
git push