-
Notifications
You must be signed in to change notification settings - Fork 5
55 lines (48 loc) · 1.44 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
55 lines (48 loc) · 1.44 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
name: Deploy VitePress Documentation
on:
# 当主分支有推送时触发
push:
branches: [main, master]
# 允许手动触发
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write # 需要写入内容权限 (用于推送到 gh-pages 分支)
steps:
# 步骤 1: 检出代码
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0 # 确保获取完整的提交历史
# 步骤 2: 设置 Node.js 环境
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
# 步骤 3: 设置 pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 10
# 步骤 4: 安装依赖
- name: Install dependencies
run: |
cd docs
pnpm install
# 步骤 5: 生成静态文档
- name: Build VitePress documentation
run: |
cd docs
pnpm run docs:build
# 步骤 6: 部署到 GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
# 文档构建产物目录 (VitePress 默认输出目录)
publish_dir: ./docs/.vitepress/dist
# 提交信息
commit_message: "Deploy VitePress docs for ${{ github.sha }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages