Repository navigation
ci: push the documentation to the gh-pages branch #138
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: "📚 Documentation" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/documentation.yml' | |
| - 'docs/**/*' | |
| - "loopstructural/**/*.py" | |
| - "loopstructural/metadata.txt" | |
| - 'requirements/documentation.txt' | |
| tags: | |
| - "*" | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - ".github/workflows/documentation.yml" | |
| - docs/**/* | |
| - requirements/documentation.txt | |
| workflow_dispatch: | |
| # GitHub Pages serves the gh-pages branch, so the GITHUB_TOKEN must be able | |
| # to push to it. | |
| permissions: | |
| contents: write | |
| # Allow one concurrent deployment per branch/pr | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| PYTHON_VERSION: "3.12" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get source code | |
| uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| cache: "pip" | |
| cache-dependency-path: "requirements/documentation.txt" | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Cache Sphinx cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: docs/_build/cache | |
| key: ${{ runner.os }}-sphinx-${{ hashFiles('docs/**/*') }} | |
| restore-keys: | | |
| ${{ runner.os }}-sphinx- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install -U pip setuptools wheel | |
| python -m pip install -U -r requirements/documentation.txt | |
| - name: Build doc using Sphinx | |
| run: sphinx-build -b html -j auto -d docs/_build/cache -q docs docs/_build/html | |
| - name: Save build doc as artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: documentation | |
| path: docs/_build/html/* | |
| if-no-files-found: error | |
| retention-days: 30 | |
| - name: Deploy to GitHub Pages | |
| if: ${{ github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' ) }} | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_branch: gh-pages | |
| publish_dir: docs/_build/html/ | |
| force_orphan: true |