forked from KaiserY/trpl-zh-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 2.77 KB
/
main.yml
File metadata and controls
78 lines (65 loc) · 2.77 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: Deploy to GitHub Pages
on:
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow pushing to gh-pages branch
permissions:
contents: write
env:
MDBOOK_VERSION: 0.5.2
MDBOOK_TYPST_PDF_VERSION: 0.7.0
TYPST_VERSION: 0.12.0
jobs:
deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
# 1. 安装依赖
- uses: actions/checkout@v4
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.90 -c rust-docs
rustup default 1.90
- name: Install mdbook & mdbook-typst-pdf
run: |
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
curl -sSL https://github.com/KaiserY/mdbook-typst-pdf/releases/download/v${MDBOOK_TYPST_PDF_VERSION}/mdbook-typst-pdf-x86_64-unknown-linux-musl.tar.xz | tar -xJ --directory=bin --strip-components=1
echo "$(pwd)/bin" >> ${GITHUB_PATH}
- name: Install fonts
run: |
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
sudo apt-get -y install msttcorefonts
mkdir fonts
mkdir -p ~/.local/share/fonts
# 下载中文字体
curl -sL -o Noto_Sans_SC.zip https://github.com/notofonts/noto-cjk/releases/download/Sans2.004/08_NotoSansCJKsc.zip
unzip Noto_Sans_SC.zip -d fonts/Noto_Sans_SC
# 下载等宽字体
curl -sL -o Noto_Sans_Mono.zip https://github.com/notofonts/latin-greek-cyrillic/releases/download/NotoSansMono-v2.014/NotoSansMono-v2.014.zip
unzip Noto_Sans_Mono.zip -d fonts/Noto_Sans_Mono
# 下载基础字体
curl -sL -o Noto_Sans.zip https://github.com/notofonts/latin-greek-cyrillic/releases/download/NotoSans-v2.013/NotoSans-v2.013.zip
unzip Noto_Sans.zip -d fonts/Noto_Sans
# 安装字体
mv fonts/* ~/.local/share/fonts/
fc-cache -rv
# 2. 编译
- name: Build book
run: mdbook build
# 2.5. 复制 PDF 到 HTML 目录
- name: Copy PDF to HTML directory
run: |
mkdir -p book/html/pdf
cp book/typst-pdf/*.pdf book/html/pdf/ || echo "No PDF files found"
# 3. 上传产物到 gh-pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/html
publish_branch: gh-pages
force_orphan: true