|
| 1 | +name: "Docs: Check & Deploy" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - "docs/**" |
| 9 | + - "mkdocs.yaml" |
| 10 | + - "JsonApiToolkit/**" |
| 11 | + - ".github/workflows/docs.yml" |
| 12 | + pull_request: |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + packages: read |
| 18 | + pages: write |
| 19 | + id-token: write |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: pages-${{ github.event_name == 'pull_request' && github.head_ref || 'deploy' }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + changes: |
| 27 | + name: Detect changes |
| 28 | + if: github.event_name == 'pull_request' |
| 29 | + runs-on: ubuntu-latest |
| 30 | + permissions: |
| 31 | + contents: read |
| 32 | + pull-requests: read |
| 33 | + outputs: |
| 34 | + docs: ${{ steps.filter.outputs.docs }} |
| 35 | + steps: |
| 36 | + - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 |
| 37 | + id: filter |
| 38 | + with: |
| 39 | + filters: | |
| 40 | + docs: |
| 41 | + - 'docs/**' |
| 42 | + - 'mkdocs.yaml' |
| 43 | + - 'CHANGELOG.md' |
| 44 | + - 'JsonApiToolkit/**' |
| 45 | + - '.github/workflows/docs.yml' |
| 46 | +
|
| 47 | + build: |
| 48 | + name: "Docs: Build" |
| 49 | + needs: changes |
| 50 | + if: always() && (needs.changes.result == 'skipped' || needs.changes.outputs.docs == 'true') |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 54 | + with: |
| 55 | + fetch-depth: 0 |
| 56 | + |
| 57 | + - uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5 |
| 58 | + with: |
| 59 | + dotnet-version: 10.0.x |
| 60 | + source-url: https://nuget.pkg.github.com/Intility/index.json |
| 61 | + env: |
| 62 | + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 |
| 65 | + with: |
| 66 | + python-version: "3.13" |
| 67 | + |
| 68 | + - name: Build library (for API XML docs) |
| 69 | + env: |
| 70 | + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + run: dotnet build JsonApiToolkit/JsonApiToolkit.csproj -c Release -o JsonApiToolkit/bin/docs |
| 72 | + |
| 73 | + - name: Restore .NET tools |
| 74 | + env: |
| 75 | + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + run: dotnet tool restore |
| 77 | + |
| 78 | + - name: Generate API reference |
| 79 | + run: dotnet tool run mkdocs-dotnet-api -- --input JsonApiToolkit/bin/docs --output docs/api --strict |
| 80 | + |
| 81 | + - name: Install Python dependencies |
| 82 | + run: uv venv && uv pip install -r docs/requirements.txt |
| 83 | + |
| 84 | + - name: Build Documentation |
| 85 | + run: uv run mkdocs build --strict |
| 86 | + |
| 87 | + - name: Upload artifact |
| 88 | + if: github.event_name != 'pull_request' |
| 89 | + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 |
| 90 | + with: |
| 91 | + path: "site" |
| 92 | + |
| 93 | + deploy: |
| 94 | + name: Deploy |
| 95 | + if: always() && needs.build.result == 'success' && github.event_name != 'pull_request' |
| 96 | + runs-on: ubuntu-latest |
| 97 | + needs: build |
| 98 | + environment: |
| 99 | + name: github-pages |
| 100 | + url: ${{ steps.deployment.outputs.page_url }} |
| 101 | + steps: |
| 102 | + - name: Deploy to GitHub Pages |
| 103 | + id: deployment |
| 104 | + uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 |
0 commit comments