-
Notifications
You must be signed in to change notification settings - Fork 13
104 lines (89 loc) · 3.52 KB
/
deploy.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
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
103
104
name: Build VitePress, Pull Types, and Push to Private Repo
on:
push:
branches: [main]
jobs:
setup-and-build:
runs-on: self-hosted
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull types from type repo
run: |
if ! grep -q github.com ~/.ssh/known_hosts; then
ssh-keyscan github.com >> ~/.ssh/known_hosts
fi
GIT_SSH_COMMAND='ssh -i /home/mihono/.ssh/id_rsa' git clone --depth 1 [email protected]:M1hono/CrychicDocTypes.git type_repo
cp -r type_repo/typefiles .
rm -rf type_repo
echo "Types pulled successfully"
- name: Configure Yarn to use a faster registry
run: yarn config set registry https://registry.npmmirror.com
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.17.0"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build VitePress site
env:
NODE_OPTIONS: --max-old-space-size=8192
run: |
echo "Building VitePress site..."
yarn docs:build
echo "VitePress site build completed"
# 上传 .vitepress/dist 目录为工件
- name: Upload VitePress site as artifact
uses: actions/upload-artifact@v3
with:
name: vitepress-dist
path: .vitepress/dist
push-to-private-repo:
needs: setup-and-build
runs-on: self-hosted
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
# 下载 .vitepress/dist 目录
- name: Download VitePress site artifact
uses: actions/download-artifact@v3
with:
name: vitepress-dist
- name: Setup Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Clone private repo
run: |
if ! grep -q github.com ~/.ssh/known_hosts; then
ssh-keyscan github.com >> ~/.ssh/known_hosts
fi
GIT_SSH_COMMAND='ssh -i /home/mihono/.ssh/id_rsa' git clone --depth 1 [email protected]:M1hono/CrychicDocSynchronization.git temp_repo
- name: Copy necessary files
run: |
if [ -d temp_repo/.github ]; then
cp -r temp_repo/.github .vitepress/dist/
fi
if [ -f temp_repo/CNAME ]; then
cp temp_repo/CNAME .vitepress/dist/
fi
- name: Push to private repo
run: |
cd .vitepress/dist
git init
git add -A
git commit -m "Update documentation"
GIT_SSH_COMMAND='ssh -i /home/mihono/.ssh/id_rsa' git push --force [email protected]:M1hono/CrychicDocSynchronization.git HEAD:main
cleanup:
needs: push-to-private-repo
runs-on: self-hosted
steps:
- name: Remove temporary files
run: |
rm -rf typefiles
rm -rf .vitepress/dist
rm -rf temp_repo