|
| 1 | +name: CI Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-docs: |
| 11 | + name: "Build Docs" |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v6 |
| 17 | + with: |
| 18 | + fetch-depth: 0 # Full history for accurate page timestamps |
| 19 | + |
| 20 | + - uses: actions/setup-python@v6 |
| 21 | + with: |
| 22 | + python-version: "3.11" |
| 23 | + |
| 24 | + - name: Install package and dependencies |
| 25 | + run: | |
| 26 | + python -m pip install uv |
| 27 | + uv sync |
| 28 | + uv pip install great-docs |
| 29 | +
|
| 30 | + - name: Set up Quarto |
| 31 | + uses: quarto-dev/quarto-actions/setup@v2 |
| 32 | + |
| 33 | + - name: Build docs |
| 34 | + run: uv run great-docs build |
| 35 | + |
| 36 | + - name: Save docs artifact |
| 37 | + uses: actions/upload-artifact@v7 |
| 38 | + with: |
| 39 | + name: docs-html |
| 40 | + path: great-docs/_site |
| 41 | + include-hidden-files: true |
| 42 | + |
| 43 | + - name: Upload build timings |
| 44 | + uses: actions/upload-artifact@v7 |
| 45 | + with: |
| 46 | + name: build-timings |
| 47 | + path: great-docs/_site/build-timings.json |
| 48 | + |
| 49 | + publish-docs: |
| 50 | + name: "Publish Docs" |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: "build-docs" |
| 53 | + if: github.ref == 'refs/heads/main' |
| 54 | + permissions: |
| 55 | + pages: write |
| 56 | + id-token: write |
| 57 | + environment: |
| 58 | + name: github-pages |
| 59 | + url: ${{ steps.deployment.outputs.page_url }} |
| 60 | + steps: |
| 61 | + - uses: actions/download-artifact@v7 |
| 62 | + with: |
| 63 | + name: docs-html |
| 64 | + path: great-docs/_site |
| 65 | + |
| 66 | + - name: Upload Pages artifact |
| 67 | + uses: actions/upload-pages-artifact@v5 |
| 68 | + with: |
| 69 | + path: great-docs/_site |
| 70 | + include-hidden-files: true |
| 71 | + |
| 72 | + - name: Deploy to GitHub Pages |
| 73 | + id: deployment |
| 74 | + uses: actions/deploy-pages@v5 |
| 75 | + |
| 76 | + preview-docs: |
| 77 | + name: "Preview Docs" |
| 78 | + runs-on: ubuntu-latest |
| 79 | + needs: "build-docs" |
| 80 | + if: github.event_name == 'pull_request' |
| 81 | + permissions: |
| 82 | + deployments: write |
| 83 | + pull-requests: write |
| 84 | + steps: |
| 85 | + - uses: actions/download-artifact@v7 |
| 86 | + with: |
| 87 | + name: docs-html |
| 88 | + path: great-docs/_site |
| 89 | + |
| 90 | + # Start deployment |
| 91 | + - name: Configure pull release name |
| 92 | + if: ${{ github.event_name == 'pull_request' }} |
| 93 | + run: | |
| 94 | + echo "RELEASE_NAME=pr-${{ github.event.number }}" >> $GITHUB_ENV |
| 95 | +
|
| 96 | + - name: Configure branch release name |
| 97 | + if: ${{ github.event_name != 'pull_request' }} |
| 98 | + run: | |
| 99 | + # use branch name, but replace slashes. E.g. feat/a -> feat-a |
| 100 | + echo "RELEASE_NAME=${GITHUB_REF_NAME//\//-}" >> $GITHUB_ENV |
| 101 | +
|
| 102 | + # Deploy |
| 103 | + - name: Create Github Deployment |
| 104 | + uses: bobheadxi/deployments@v1 |
| 105 | + id: deployment |
| 106 | + if: ${{ !github.event.pull_request.head.repo.fork }} |
| 107 | + with: |
| 108 | + step: start |
| 109 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + env: ${{ env.RELEASE_NAME }} |
| 111 | + ref: ${{ github.head_ref }} |
| 112 | + logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
0 commit comments