-
Notifications
You must be signed in to change notification settings - Fork 13
86 lines (71 loc) · 3.15 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
name: Build VitePress, Pull Types, and Push to Private Repo
on:
push:
branches: [main]
jobs:
setup-build-and-push:
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"
- name: Setup Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
# 修改这部分来从新仓库拉取 workflow
- name: Copy workflow file
run: |
# 创建目标目录
mkdir -p .vitepress/dist/.github/workflows/ || exit 1
# 从新仓库克隆 workflow 文件
GIT_SSH_COMMAND='ssh -i /home/mihono/.ssh/id_rsa' git clone --depth 1 [email protected]:M1hono/CrychicDocWorkflow.git workflow_repo
# 复制 workflow 文件
cp workflow_repo/.github/workflows/deploy.yml .vitepress/dist/.github/workflows/ || exit 1
# 清理临时仓库
rm -rf workflow_repo
if [ -f .vitepress/dist/.github/workflows/deploy.yml ]; then
echo "Workflow 文件复制成功"
else
echo "错误:Workflow 文件复制失败"
exit 1
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
echo "Push completed"
- name: Cleanup
run: |
rm -rf typefiles
rm -rf .vitepress/dist
rm -rf temp_repo
echo "Cleanup completed"