|
| 1 | +name: Build and Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, master] |
| 6 | + paths: |
| 7 | + - "docs/**" |
| 8 | + - "code_execution/**" |
| 9 | + - ".github/workflows/docs.yml" |
| 10 | + pull_request: |
| 11 | + branches: [main, master] |
| 12 | + paths: |
| 13 | + - "docs/**" |
| 14 | + - "code_execution/**" |
| 15 | + |
| 16 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + pages: write |
| 20 | + id-token: write |
| 21 | + |
| 22 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 23 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 24 | +concurrency: |
| 25 | + group: "pages" |
| 26 | + cancel-in-progress: false |
| 27 | + |
| 28 | +jobs: |
| 29 | + build: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v4 |
| 37 | + with: |
| 38 | + python-version: "3.10" |
| 39 | + |
| 40 | + - name: Cache pip dependencies |
| 41 | + uses: actions/cache@v3 |
| 42 | + with: |
| 43 | + path: ~/.cache/pip |
| 44 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', 'docs/requirements.txt') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-pip- |
| 47 | +
|
| 48 | + - name: Install dependencies |
| 49 | + run: | |
| 50 | + python -m pip install --upgrade pip |
| 51 | + pip install -r docs/requirements.txt |
| 52 | + pip install -e . |
| 53 | +
|
| 54 | + - name: Setup Pages |
| 55 | + id: pages |
| 56 | + uses: actions/configure-pages@v3 |
| 57 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 58 | + |
| 59 | + - name: Build documentation |
| 60 | + run: | |
| 61 | + cd docs |
| 62 | + make clean || true |
| 63 | + sphinx-build -b html . _build/html |
| 64 | + # Create .nojekyll file to serve files with underscores |
| 65 | + touch _build/html/.nojekyll |
| 66 | +
|
| 67 | + - name: Upload documentation artifacts |
| 68 | + uses: actions/upload-artifact@v3 |
| 69 | + with: |
| 70 | + name: documentation |
| 71 | + path: docs/_build/html/ |
| 72 | + |
| 73 | + - name: Upload to GitHub Pages |
| 74 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 75 | + uses: actions/upload-pages-artifact@v2 |
| 76 | + with: |
| 77 | + path: docs/_build/html/ |
| 78 | + |
| 79 | + deploy: |
| 80 | + # Deploy to GitHub Pages |
| 81 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 82 | + environment: |
| 83 | + name: github-pages |
| 84 | + url: ${{ steps.deployment.outputs.page_url }} |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: build |
| 87 | + steps: |
| 88 | + - name: Deploy to GitHub Pages |
| 89 | + id: deployment |
| 90 | + uses: actions/deploy-pages@v2 |
0 commit comments