forked from kakushi-w/wikit
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (60 loc) · 2.28 KB
/
Copy pathsync.yml
File metadata and controls
72 lines (60 loc) · 2.28 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 upstream
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
sync-code:
runs-on: ubuntu-latest
steps:
- name: Sync fork from upstream
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh repo sync WikitTeam/wikit \
--source kakushi-w/wikit \
--force
sync-releases:
needs: sync-code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Sync releases (update in place, no duplicates)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tags=$(gh api repos/kakushi-w/wikit/releases --jq '.[].tag_name')
for tag in $tags; do
echo "=== $tag ==="
release_json=$(gh api repos/kakushi-w/wikit/releases/tags/$tag)
echo "$release_json" | jq -e . >/dev/null 2>&1 || { echo " skip: invalid JSON"; continue; }
name=$(echo "$release_json" | jq -r '.name // .tag_name')
body=$(echo "$release_json" | jq -r '.body // ""')
draft=$(echo "$release_json" | jq -r '.draft')
prerelease=$(echo "$release_json" | jq -r '.prerelease')
# 已同步过的 release 直接跳过,不产生任何多余步骤
if gh release view "$tag" --repo WikitTeam/wikit >/dev/null 2>&1; then
echo " already synced, skipping (up to date)"
continue
fi
# 只在首次缺失时创建一次
echo " release missing, creating..."
gh release create "$tag" \
--repo WikitTeam/wikit \
--title "$name" \
--notes "$body" \
--draft="$draft" \
--prerelease="$prerelease"
# 同步全部 assets(含 5 个二进制 + SHA256SUMS)
echo "$release_json" | jq -c '.assets[]' | while IFS= read -r asset; do
fname=$(echo "$asset" | jq -r '.name')
dl=$(echo "$asset" | jq -r '.browser_download_url')
echo " uploading: $fname"
curl -fsSL "$dl" -o "$fname"
gh release upload "$tag" "$fname" --repo WikitTeam/wikit --clobber
rm -f "$fname"
done
echo " done: $tag"
done