trpl-zh-cn/.github/workflows/main.yml
2023-12-17 21:46:29 +08:00

61 lines
1.9 KiB
YAML

name: CI
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@main
- name: Update rustup
run: rustup self update
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.74.1 -c rust-docs
rustup default 1.74.1
- name: Install mdbook
run: |
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.36/mdbook-v0.4.36-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "$(pwd)/bin" >> ${GITHUB_PATH}
- name: Install mdbook-typst-pdf
run: |
curl -sL -o bin/mdbook-typst-pdf https://github.com/KaiserY/mdbook-typst-pdf/releases/download/0.1.1/mdbook-typst-pdf-x86_64-unknown-linux-gnu
chmod +x bin/mdbook-typst-pdf
echo "$(pwd)/bin" >> ${GITHUB_PATH}
- name: Install font
run: |
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
sudo apt-get -y install msttcorefonts fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core
sudo apt-get -y install ttf-wqy*
fc-cache -f -v
- name: Report versions
run: |
rustup --version
rustc -Vv
mdbook --version
- name: Run mdBook Build
run: |
mdbook build
mv book/html/* book/
mv "book/typst-pdf/Rust 程序设计语言 简体中文版.pdf" book/
rm -r book/html/
rm -rf book/typst-pdf/
- name: Deploy gh-pages
if: ${{ github.ref == 'refs/heads/main' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book
force_orphan: true
enable_jekyll: true