-
Notifications
You must be signed in to change notification settings - Fork 14
66 lines (55 loc) · 1.82 KB
/
Copy pathdocs.yml
File metadata and controls
66 lines (55 loc) · 1.82 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
64
65
66
name: Deploy docs to GitHub Pages
on:
push:
# 限定分支触发,排除标签:发布打的 tag 会触发部署,但 github-pages
# 环境保护规则不允许从 tag 部署,导致 deploy 被拒。
branches: [ '**' ]
paths: [ 'docs/**', '.github/workflows/docs.yml' ]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# 同一时间只跑一个部署,新提交自动取消进行中的旧部署
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: docs/pnpm-lock.yaml
- name: Install dependencies
# 用 --no-frozen-lockfile:docs 为独立子项目,pnpm 在 CI 中会向上读到根
# package.json 的 overrides 导致 frozen 校验失败;文档站构建无需锁定一致性。
run: pnpm install --no-frozen-lockfile
- name: Build
run: pnpm build
- uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# 用绝对路径:job 设了 working-directory: docs,upload-pages-artifact 内部
# 的 tar 会继承该目录,相对路径 docs/dist 会被当成 docs/docs/dist 而找不到。
path: ${{ github.workspace }}/docs/dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4