-
Notifications
You must be signed in to change notification settings - Fork 9
63 lines (57 loc) · 1.89 KB
/
Copy pathstatic.yml
File metadata and controls
63 lines (57 loc) · 1.89 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
56
57
58
59
60
61
62
63
# 自动构建 VitePress 站点,并发布到 GitHub Pages
#
name: 自动发布 VitePress 站点到 GitHub Pages
on:
# 当代码推送到 master 分支时自动运行
push:
branches: [master]
# 允许在 GitHub Actions 页面手动触发发布
workflow_dispatch:
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 不取消正在进行的发布任务,避免线上发布中断
concurrency:
group: pages
cancel-in-progress: false
jobs:
# 构建站点
build:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
with:
fetch-depth: 0 # 如果不需要 lastUpdated,可以移除此项
# - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消注释
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
- name: 配置 Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn # 根据包管理器可改为 npm / pnpm / yarn
- name: 配置 GitHub Pages
uses: actions/configure-pages@v4
- name: 安装依赖
run: yarn install # 也可以使用 npm ci / pnpm install / yarn install / bun install
- name: 构建 VitePress 站点
run: yarn docs:build # 也可以使用 npm run docs:build / pnpm docs:build / bun run docs:build
- name: 上传构建产物
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
# 发布站点
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: 发布站点
steps:
- name: 发布到 GitHub Pages
id: deployment
uses: actions/deploy-pages@v4