forked from mswnlz/mswnlz.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (84 loc) · 2.95 KB
/
deploy.yml
File metadata and controls
102 lines (84 loc) · 2.95 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Deploy VitePress site to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
repository_dispatch:
types: [content-updated]
schedule:
# 每20天早上8点自动检查更新(北京时间,UTC+8,所以是UTC 0点)
- cron: '0 0 */20 * *'
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write # For actions/checkout
pages: write # For actions/deploy-pages
id-token: write # For actions/deploy-pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: true
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm install
- name: Checkout content repositories
run: |
set -euo pipefail
# Create directory for content sources
mkdir -p content-source
# List of content repositories
repos=("AIknowledge" "auto" "book" "chinese-traditional" "cross-border" "curriculum" "edu-knowlege" "games" "healthy" "movies" "self-media" "tools")
failed_repos=()
# Clone each repository
for repo in "${repos[@]}"; do
echo "Cloning $repo..."
if ! git clone --depth 1 "https://github.com/xi7ang/$repo.git" "content-source/$repo"; then
echo "::error::Failed to clone $repo"
failed_repos+=("$repo")
fi
done
if [ ${#failed_repos[@]} -gt 0 ]; then
echo "Failed content repositories: ${failed_repos[*]}"
exit 1
fi
- name: Copy latest content from all repositories
run: |
# Set up paths
export SOURCE_BASE_DIR="./content-source"
export TARGET_DOCS_DIR="./docs"
export REQUIRE_ALL_REPOS="true"
# Run the content synchronization
bash ./copy_content.sh
- name: Fetch latest commits
run: npm run fetch-commits
- name: Build VitePress site
run: npm run build
- name: Fix pagefind WASM filename mismatch
run: |
# pagefind 1.5.0 Extended 生成 wasm.unknown.pagefind
# 但 pagefind.js 内部查找 pagefind_bg.wasm
# 创建软链接让两者兼容
cd ./docs/.vitepress/dist/pagefind
if [ -f "wasm.unknown.pagefind" ]; then
ln -sf wasm.unknown.pagefind pagefind_bg.wasm
echo "Created symlink: wasm.unknown.pagefind -> pagefind_bg.wasm"
fi
ls -la *.wasm *.pagefind 2>/dev/null || echo "No WASM files found"
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: ./docs/.vitepress/dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5