Skip to content

Deploy Sphinx Documentation to GitHub Pages #94

Deploy Sphinx Documentation to GitHub Pages

Deploy Sphinx Documentation to GitHub Pages #94

Workflow file for this run

name: Deploy Sphinx Documentation to GitHub Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
paths:
- 'code/docs/**'
- 'code/.github/workflows/pages.yml'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'code/docs/requirements.txt'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r code/docs/requirements.txt
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Build with Sphinx
run: |
cd code/docs
# English (default) at site root
sphinx-build -b html -d _build/doctrees/en -t en . _build/html
# Chinese at /zh/
sphinx-build -b html -d _build/doctrees/zh -t zh -D language=zh_CN . _build/html/zh
- name: Test built site
run: |
test -f code/docs/_build/html/index.html || (echo "Site build failed - index.html not found" && exit 1)
test -f code/docs/_build/html/zh/index.html || (echo "ZH site build failed - zh/index.html not found" && exit 1)
echo "Site built successfully"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: "code/docs/_build/html/"
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4