Skip to content

Commit 0dbfad0

Browse files
authored
Merge pull request #1 from volcengine/deploy-vitepress-to-github-pages
feat: create deploy-docs.yml
2 parents 1f2c503 + 77c4ea3 commit 0dbfad0

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/deploy-docs.yml

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

0 commit comments

Comments
 (0)