chore(CI): add publish workflow #99
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: Build and Deploy Documentation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Create and activate virtual environment | |
| run: | | |
| python -m venv venv | |
| source venv/bin/activate | |
| - name: Install package and development dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install .[dev] | |
| - name: Build documentation | |
| run: | | |
| source venv/bin/activate | |
| sphinx-build -b html docs/source docs/build/ | |
| - name: Commit and Stash Documentation | |
| run: | | |
| git add -f docs/build/ | |
| git stash | |
| - name: Checkout gh-pages | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| - name: Configure Git | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| - name: Cleanup Old Folders | |
| run: | | |
| rm -rf _static/ | |
| rm -rf _modules/ | |
| rm -rf _sources/ | |
| rm -rf examples/ | |
| rm -rf modules/ | |
| - name: Deploy to gh-pages | |
| run: | | |
| git stash pop | |
| mv -f docs/build/* . | |
| rm -rf docs/build | |
| git add . | |
| git commit -m "Auto update docs" | |
| git push |