-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (67 loc) · 1.94 KB
/
Copy pathdocs-deployment.yml
File metadata and controls
78 lines (67 loc) · 1.94 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
name: 部署文档网站
on:
push:
branches:
- main
paths:
- 'document/**'
- 'os/src/**'
- 'book.toml'
- '.github/workflows/docs-deployment.yml'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v4
- name: 安装 Rust 工具链
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2025-01-18
targets: riscv64gc-unknown-none-elf
components: rust-src, rustfmt, clippy
- name: 安装 mdBook
run: |
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.40/mdbook-v0.4.40-x86_64-unknown-linux-gnu.tar.gz | tar -xz
chmod +x mdbook
sudo mv mdbook /usr/local/bin/
- name: 构建 mdBook 文档
run: |
python3 scripts/rewrite_links.py document/
mdbook build
- name: 构建 Rust API 文档
run: |
cd os
cargo doc --no-deps --target riscv64gc-unknown-none-elf
- name: 合并文档到统一目录
run: |
mkdir -p site
# 复制 mdBook 输出
cp -r book/* site/
# 删除 mdBook 生成的 api 目录(如果存在),避免与 cargo doc 输出冲突
rm -rf site/api
# 复制 cargo doc 输出到 api 子目录
mkdir -p site/api
cp -r os/target/riscv64gc-unknown-none-elf/doc/* site/api/
- name: 上传 Pages 构件
uses: actions/upload-pages-artifact@v3
with:
path: ./site
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: 部署到 GitHub Pages
id: deployment
uses: actions/deploy-pages@v4