Skip to content

Commit 1e4e6e5

Browse files
committed
feat(deploy): add VitePress site deployment to GitHub Pages
1 parent 22cfa8a commit 1e4e6e5

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Deploy VitePress site to Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
# 允许你从 Actions 选项卡手动运行此工作流程
8+
workflow_dispatch:
9+
10+
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
17+
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
18+
concurrency:
19+
group: pages
20+
cancel-in-progress: false
21+
22+
jobs:
23+
# 构建工作
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
31+
- uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
32+
with:
33+
version: 9
34+
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
35+
- name: Setup Node
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: 20
39+
cache: pnpm # 或 npm / yarn
40+
- name: Setup Pages
41+
uses: actions/configure-pages@v4
42+
- name: Install dependencies
43+
run: pnpm install # 或 npm ci / yarn install / bun install
44+
- name: Build with VitePress
45+
run: pnpm docs:build # 或 npm run docs:build / yarn docs:build / bun run docs:build
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: docs/.vitepress/dist
50+
51+
# 部署工作
52+
deploy:
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
needs: build
57+
runs-on: ubuntu-22.04
58+
name: Deploy
59+
steps:
60+
- name: Deploy to GitHub Pages
61+
id: deployment
62+
uses: peaceiris/actions-gh-pages@v3
63+
with:
64+
external_repository: ZCST-OpenCS-Source/ZCST-OpenCS.github.io
65+
publish_branch: main
66+
publish_dir: docs/.vitepress/dist

0 commit comments

Comments
 (0)