mirror of
https://github.com/openmlsys/openmlsys-zh.git
synced 2026-04-01 18:01:13 +08:00
Switch the docs deployment workflow to the official GitHub Pages actions flow and verify it uses Pages action outputs for the deployment URL.
80 lines
2.1 KiB
YAML
80 lines
2.1 KiB
YAML
name: Deploy Docs
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: github-pages
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- id: pages
|
|
uses: actions/configure-pages@v5
|
|
|
|
- name: Set up Python 3.10
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install Rust toolchain
|
|
run: |
|
|
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Install mdBook
|
|
run: cargo install mdbook --locked
|
|
|
|
- name: Run mdBook regression tests
|
|
run: |
|
|
python3 -m unittest discover -s tests -p 'test_prepare_mdbook.py'
|
|
python3 -m unittest discover -s tests -p 'test_prepare_mdbook_zh.py'
|
|
python3 -m unittest discover -s tests -p 'test_assemble_docs_publish_tree.py'
|
|
python3 -m unittest discover -s tests -p 'test_ensure_book_resources.py'
|
|
python3 -m unittest discover -s tests -p 'test_mdbook_mathjax.py'
|
|
|
|
- name: Build English HTML with mdBook
|
|
run: bash build_mdbook.sh
|
|
|
|
- name: Build Chinese HTML with mdBook
|
|
run: bash build_mdbook_zh.sh
|
|
|
|
- name: Assemble GitHub Pages artifact
|
|
env:
|
|
DEPLOY_TARGET_URL: ${{ steps.pages.outputs.base_url }}
|
|
run: |
|
|
echo "Deploy target: ${DEPLOY_TARGET_URL}" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
python3 tools/assemble_docs_publish_tree.py \
|
|
--destination-root _site \
|
|
--docs-subdir . \
|
|
--en-source .mdbook/book \
|
|
--zh-source .mdbook-zh/book
|
|
|
|
- name: Upload GitHub Pages artifact
|
|
uses: actions/upload-pages-artifact@v4
|
|
with:
|
|
path: _site
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- id: deployment
|
|
uses: actions/deploy-pages@v4
|