Skip to content

Manual Rebuild of Documentation of all versions #1

Manual Rebuild of Documentation of all versions

Manual Rebuild of Documentation of all versions #1

name: Manual Rebuild Documentation
on:
workflow_dispatch:
jobs:
rebuild:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch full history and all tags
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
python-version: 3.12 # Specify the Python version compatible with your environment
environment-file: docs/environment.yml # Use your environment.yml to install dependencies
activate-environment: readthedocs # Name from environment.yml
auto-activate-base: false
- name: Rebuild all versions using sphinx-multiversion
run: sphinx-multiversion docs/source _build/html
- name: Create index.html redirect
run: |
git fetch origin gh-pages
git checkout gh-pages
# Determine redirect target
tagged_versions=$(ls _build/html | grep '^v' || true)
if [ -n "$tagged_versions" ]; then
latest_tag=$(echo "$tagged_versions" | sort -V | tail -n 1)
redirect_target="$latest_tag/index.html"
else
redirect_target="master/index.html"
fi
# Ensure _build/html directory exists
mkdir -p _build/html
# Ensure index.html can be overwritten
if [ -f _build/html/index.html ]; then
echo "Overwriting existing _build/html/index.html"
rm _build/html/index.html
fi
# Create index.html for redirect
echo '<!DOCTYPE html>' > _build/html/index.html
echo '<html>' >> _build/html/index.html
echo '<head>' >> _build/html/index.html
echo ' <meta http-equiv="refresh" content="0; url='$redirect_target'">' >> _build/html/index.html
echo ' <title>Redirecting...</title>' >> _build/html/index.html
echo '</head>' >> _build/html/index.html
echo '<body>' >> _build/html/index.html
echo ' <p>If you are not redirected automatically, follow this <a href="'$redirect_target'">link</a>.</p>' >> _build/html/index.html
echo '</body>' >> _build/html/index.html
echo '</html>' >> _build/html/index.html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html