docs: custom multi-version build with git worktree, CSS fix for long … #332
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 Sphinx documentation to Pages | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'docs/sphinx_doc/**/*' | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
jobs: | |
pages: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ "3.11" ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get git tags | |
run: | | |
git fetch --all --tags | |
git branch -a | |
git tag | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@master | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -v -e .[dev] | |
- id: build | |
name: Build Documentation | |
run: | | |
cd docs/sphinx_doc | |
bash build_doc.sh | |
- name: Redirect index.html | |
run: | | |
REPOSITORY_OWNER="${GITHUB_REPOSITORY_OWNER}" | |
cd docs/sphinx_doc | |
cp ./redirect.html build/index.html | |
sed -i "s/\[VERSION\]/$(python -c 'import data_juicer;print(data_juicer.__version__)')/g" build/index.html | |
sed -i "s/\[REPOSITORY_OWNER\]/${REPOSITORY_OWNER}/g" build/index.html | |
cp build/index.html build/404.html | |
- name: Upload Documentation | |
uses: actions/upload-artifact@v4 | |
with: | |
name: SphinxDoc | |
path: 'docs/sphinx_doc/build' | |
- uses: peaceiris/actions-gh-pages@v3 | |
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: 'docs/sphinx_doc/build' |