|
| 1 | +# SPDX-FileCopyrightText: 2026 LibreSign |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | + |
| 4 | +name: docs |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + validate-docs: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v6 |
| 20 | + |
| 21 | + - name: Detect minimum PHP from composer.json |
| 22 | + id: php_min |
| 23 | + run: | |
| 24 | + php_version=$(grep -Po '"php"\s*:\s*"\K[^"]+' composer.json | grep -Eo '[0-9]+\.[0-9]+' | head -n1) |
| 25 | + [[ -n "$php_version" ]] || { echo "Could not determine minimum PHP version"; exit 1; } |
| 26 | + echo "version=$php_version" >> "$GITHUB_OUTPUT" |
| 27 | +
|
| 28 | + - name: Setup PHP |
| 29 | + uses: shivammathur/setup-php@v2 |
| 30 | + with: |
| 31 | + php-version: ${{ steps.php_min.outputs.version }} |
| 32 | + |
| 33 | + - name: Setup Python |
| 34 | + uses: actions/setup-python@v6 |
| 35 | + with: |
| 36 | + python-version: '3.12' |
| 37 | + |
| 38 | + - name: Install Composer dependencies |
| 39 | + run: composer install --no-interaction --prefer-dist |
| 40 | + |
| 41 | + - name: Install PHPUnit bin dependencies |
| 42 | + run: composer bin phpunit install --no-interaction --prefer-dist |
| 43 | + |
| 44 | + - name: Install docs dependencies |
| 45 | + run: python -m pip install --upgrade pip && pip install -r requirements-docs.txt |
| 46 | + |
| 47 | + # Pull requests only validate docs. No deployment from PRs. |
| 48 | + - name: Run docs tests |
| 49 | + run: composer run docs:test |
| 50 | + |
| 51 | + deploy-docs: |
| 52 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 53 | + needs: validate-docs |
| 54 | + runs-on: ubuntu-latest |
| 55 | + permissions: |
| 56 | + contents: write |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v6 |
| 60 | + |
| 61 | + - name: Setup Python |
| 62 | + uses: actions/setup-python@v6 |
| 63 | + with: |
| 64 | + python-version: '3.12' |
| 65 | + |
| 66 | + - name: Install docs dependencies |
| 67 | + run: python -m pip install --upgrade pip && pip install -r requirements-docs.txt |
| 68 | + |
| 69 | + - name: Build docs site |
| 70 | + run: python -m mkdocs build --strict |
| 71 | + |
| 72 | + # Pushes to main publish docs to gh-pages branch. |
| 73 | + # Maintainers should configure GitHub Pages source as: |
| 74 | + # Deploy from branch -> gh-pages -> /root |
| 75 | + - name: Deploy site to gh-pages branch |
| 76 | + uses: peaceiris/actions-gh-pages@v4 |
| 77 | + with: |
| 78 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + publish_dir: ./site |
| 80 | + publish_branch: gh-pages |
| 81 | + force_orphan: true |
0 commit comments