-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (68 loc) · 1.96 KB
/
deploy-docs.yml
File metadata and controls
79 lines (68 loc) · 1.96 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
67
68
69
70
71
72
73
74
75
76
77
78
79
name: 构建并部署文档
on:
push:
branches: [ main ]
tags-ignore:
- '**' # 忽略所有标签推送,避免与基于标签的部署冲突
paths:
- '**'
- '.github/workflows/deploy-docs.yml'
pull_request:
branches: [ main ]
paths:
- '**'
repository_dispatch:
types: [docs-updated]
# 设置权限以允许部署到 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 # 获取完整历史记录以便 Docusaurus 可以计算最后修改时间
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: ./package-lock.json
- name: 安装依赖
run: npm ci
- name: 构建网站
run: npm run build
- name: 设置 Pages
uses: actions/configure-pages@v4
- name: 上传构建产物
uses: actions/upload-pages-artifact@v3
with:
path: ./build
# 部署作业
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: 部署到 GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: 部署成功通知
run: |
echo "✅ 文档已成功部署到 GitHub Pages"
echo "📝 提交: ${{ github.sha }}"
echo "🔗 分支: ${{ github.ref_name }}"
echo "🌐 访问地址: ${{ steps.deployment.outputs.page_url }}"