Build and Deploy gh-pages sphinx documentation #9
This file contains 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: Build and Deploy gh-pages sphinx documentation | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'docs/**' | |
workflow_dispatch: # This adds the manual trigger | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' # Use the Python version you need | |
- name: Install Pandoc | |
run: sudo apt-get install pandoc | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install sphinx nbsphinx sphinx_rtd_theme | |
pip install -r requirements.txt | |
- name: Build documentation | |
run: | | |
sphinx-build -b html docs/source docs/build/html | |
- name: Upload documentation artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docs-build | |
path: docs/build/html | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Clean the root directory | |
run: | | |
rm -rf * | |
- name: Download documentation artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: docs-build | |
path: docs-build | |
- name: Deploy to GitHub Pages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ls -R | |
cp -r docs-build/* . | |
rm -rf docs-build # Remove the directory after copying its content | |
git add . | |
git commit -m 'Deploy documentation' | |
git push --force origin gh-pages | |