mirror of
https://github.com/openmlsys/openmlsys-zh.git
synced 2026-03-21 04:27:33 +08:00
77 lines
1.9 KiB
YAML
77 lines
1.9 KiB
YAML
name: Deploy Docs
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: pages
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.10
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.10'
|
|
cache: 'pip'
|
|
|
|
- name: Install pandoc
|
|
run: |
|
|
wget -q https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb
|
|
sudo dpkg -i pandoc-2.19.2-1-amd64.deb
|
|
|
|
- name: Install d2lbook
|
|
run: |
|
|
git clone https://github.com/openmlsys/d2l-book.git
|
|
cd d2l-book
|
|
# Fix Python 3.10+ incompatibility: bibtex<2.0.0 depends on oset which
|
|
# uses collections.MutableSet removed in Python 3.10.
|
|
sed -i "s/'sphinxcontrib-bibtex<2.0.0'/'sphinxcontrib-bibtex>=2.5.0'/" setup.py
|
|
python3 -m pip install .
|
|
|
|
- name: Install Python dependencies
|
|
run: python3 -m pip install -r requirements.txt sphinx-mathjax-offline
|
|
|
|
- name: Build English HTML
|
|
run: bash build_html.sh
|
|
|
|
- name: Build Chinese HTML
|
|
run: bash build_html_zh.sh
|
|
|
|
- name: Assemble site
|
|
run: |
|
|
mkdir -p _site
|
|
# English → root
|
|
cp -r en_chapters/_build/html/* _site/
|
|
# Chinese → /cn/
|
|
mkdir -p _site/cn
|
|
cp -r zh_chapters/_build/html/* _site/cn/
|
|
|
|
- name: Upload Pages artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: _site
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-22.04
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|