|
| 1 | +name: "📚 Documentation" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - '.github/workflows/documentation.yml' |
| 9 | + - 'docs/**/*' |
| 10 | + - "loopstructural/**/*.py" |
| 11 | + - "loopstructural/metadata.txt" |
| 12 | + - 'requirements/documentation.txt' |
| 13 | + tags: |
| 14 | + - "*" |
| 15 | + |
| 16 | + pull_request: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + paths: |
| 20 | + - ".github/workflows/documentation.yml" |
| 21 | + - docs/**/* |
| 22 | + - requirements/documentation.txt |
| 23 | + |
| 24 | + workflow_dispatch: |
| 25 | + |
| 26 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + pages: write |
| 30 | + id-token: write |
| 31 | + |
| 32 | +# Allow one concurrent deployment per branch/pr |
| 33 | +concurrency: |
| 34 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +env: |
| 38 | + PYTHON_VERSION: 3.9 |
| 39 | + |
| 40 | +jobs: |
| 41 | + build: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + |
| 44 | + steps: |
| 45 | + - name: Get source code |
| 46 | + uses: actions/checkout@v5 |
| 47 | + |
| 48 | + - name: Set up Python |
| 49 | + uses: actions/setup-python@v6 |
| 50 | + with: |
| 51 | + cache: "pip" |
| 52 | + cache-dependency-path: "requirements/documentation.txt" |
| 53 | + python-version: ${{ env.PYTHON_VERSION }} |
| 54 | + |
| 55 | + - name: Cache Sphinx cache |
| 56 | + uses: actions/cache@v4 |
| 57 | + with: |
| 58 | + path: docs/_build/cache |
| 59 | + key: ${{ runner.os }}-sphinx-${{ hashFiles('docs/**/*') }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-sphinx- |
| 62 | +
|
| 63 | + - name: Install dependencies |
| 64 | + run: | |
| 65 | + python -m pip install -U pip setuptools wheel |
| 66 | + python -m pip install -U -r requirements/documentation.txt |
| 67 | +
|
| 68 | + - name: Build doc using Sphinx |
| 69 | + run: sphinx-build -b html -j auto -d docs/_build/cache -q docs docs/_build/html |
| 70 | + |
| 71 | + - name: Save build doc as artifact |
| 72 | + uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: documentation |
| 75 | + path: docs/_build/html/* |
| 76 | + if-no-files-found: error |
| 77 | + retention-days: 30 |
| 78 | + |
| 79 | + |
| 80 | + - name: Setup Pages |
| 81 | + uses: actions/configure-pages@v5 |
| 82 | + if: ${{ github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' ) }} |
| 83 | + |
| 84 | + - name: Upload artifact |
| 85 | + uses: actions/upload-pages-artifact@v4 |
| 86 | + if: ${{ github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' ) }} |
| 87 | + with: |
| 88 | + # Upload entire repository |
| 89 | + path: docs/_build/html/ |
| 90 | + |
| 91 | + - name: Deploy to GitHub Pages |
| 92 | + id: deployment |
| 93 | + if: ${{ github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' ) }} |
| 94 | + uses: actions/deploy-pages@v4 |
0 commit comments