|
| 1 | +name: Documentation build |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, reopened, synchronize] |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + merge_group: |
| 9 | + types: [checks_requested] |
| 10 | +jobs: |
| 11 | + docs-build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + pull-requests: write |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v4.2.2 |
| 18 | + - name: Setup Bazel |
| 19 | + uses: bazel-contrib/setup-bazel@0.9.1 |
| 20 | + - name: Build documentation |
| 21 | + run: | |
| 22 | + bazel build //docs:github-pages && cp bazel-bin/docs/github-pages.tar . |
| 23 | + - name: Upload artifact for deployment |
| 24 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 25 | + uses: actions/upload-artifact@v4.4.0 |
| 26 | + with: |
| 27 | + name: github-pages |
| 28 | + path: ${{ github.workspace }}/github-pages.tar |
| 29 | + retention-days: 1 |
| 30 | + if-no-files-found: error |
| 31 | + - name: Upload artifact for pull request link |
| 32 | + if: github.event_name == 'pull_request' |
| 33 | + id: upload-artifact-pr |
| 34 | + uses: actions/upload-artifact@v4.4.0 |
| 35 | + with: |
| 36 | + name: github-pages-${{ github.sha }} |
| 37 | + path: ${{ github.workspace }}/github-pages.tar |
| 38 | + retention-days: 1 |
| 39 | + if-no-files-found: error |
| 40 | + - name: Comment artifact URL |
| 41 | + if: github.event_name == 'pull_request' |
| 42 | + run: | |
| 43 | + gh pr comment ${{ github.event.pull_request.number }} \ |
| 44 | + --body "Documentation artifact: ${{ steps.upload-artifact-pr.outputs.artifact-url }}" |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ github.token }} |
| 47 | + docs-deploy: |
| 48 | + environment: |
| 49 | + name: github-pages |
| 50 | + url: ${{ steps.deployment.outputs.page_url }} |
| 51 | + permissions: |
| 52 | + pages: write |
| 53 | + id-token: write |
| 54 | + runs-on: ubuntu-latest |
| 55 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 56 | + needs: docs-build |
| 57 | + steps: |
| 58 | + - name: Deploy to GitHub Pages |
| 59 | + id: deployment |
| 60 | + uses: actions/deploy-pages@v4.0.5 |
0 commit comments