Skip to content

feat: 修正pdf无中文的问题 #13

feat: 修正pdf无中文的问题

feat: 修正pdf无中文的问题 #13

Workflow file for this run

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