Adjust docs build #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Docs | |
on: | |
release: | |
types: [created] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.13" | |
- name: Install dependencies | |
run: pip install -e ".[dev]" | |
- name: Generate versions.json | |
run: | | |
cat <<EOF > docs/versions.json | |
[ | |
{ | |
"version": "latest", | |
"url": "/xarray-dataclass/latest/" | |
}, | |
{ | |
"version": "stable", | |
"url": "/xarray-dataclass/stable/" | |
} | |
] | |
EOF | |
- name: Build docs | |
run: | | |
# Set DOCS_VERSION env var according to event | |
if [[ "${{ github.event_name }}" == "release" ]]; then | |
export DOCS_VERSION=stable | |
else | |
export DOCS_VERSION=latest | |
fi | |
python -m sphinx -b html docs docs/_build | |
- name: Copy versions.json to build output | |
run: cp docs/versions.json docs/_build/ | |
- name: Deploy docs | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./docs/_build | |
destination_dir: ${{ github.event_name == 'release' && 'stable' || 'latest' }} |