|
| 1 | +name: Publish docs |
| 2 | + |
| 3 | +# Rebuilds and republishes the hosted documentation without cutting a release (no PyPI, GitHub release or |
| 4 | +# Marketplace upload). Use it to fix the docs between releases, or to point /latest/ at a given version. |
| 5 | +# Normal releases publish docs from release.yaml; this workflow is only ever run by hand. |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + ref: |
| 11 | + description: Tag or branch to build the docs from (e.g. v0.0.12, or main for an unreleased docs fix) |
| 12 | + required: true |
| 13 | + destination: |
| 14 | + description: Folder on gh-pages to publish to, either "latest" or a version folder such as "v0.0.12" |
| 15 | + required: true |
| 16 | + default: latest |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + docs: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: write |
| 26 | + # Shares the group with release.yaml's docs job so the two never push to gh-pages at the same time. |
| 27 | + concurrency: |
| 28 | + group: studio-versioned-docs |
| 29 | + cancel-in-progress: false |
| 30 | + steps: |
| 31 | + # Only "latest" or a version folder: any other value (empty, "/", "..") could delete the rest of the site. |
| 32 | + - name: Check the destination folder |
| 33 | + env: |
| 34 | + DESTINATION: ${{ inputs.destination }} |
| 35 | + run: | |
| 36 | + if [[ ! "$DESTINATION" =~ ^(latest|v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?)$ ]]; then |
| 37 | + echo "::error::destination must be 'latest' or a version folder like 'v0.0.12', not '$DESTINATION'" |
| 38 | + exit 1 |
| 39 | + fi |
| 40 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 41 | + with: |
| 42 | + ref: ${{ inputs.ref }} |
| 43 | + - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 |
| 44 | + # The hosted copy carries usage analytics, as in release.yaml (see docs/conf.py). |
| 45 | + - run: make docs |
| 46 | + env: |
| 47 | + STUDIO_DOCS_ANALYTICS: "1" |
| 48 | + # Without keep_files, only the destination folder is replaced; every other folder on gh-pages is left alone. |
| 49 | + - name: Publish |
| 50 | + uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4 |
| 51 | + with: |
| 52 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + publish_dir: docs/_build/html |
| 54 | + destination_dir: ${{ inputs.destination }} |
0 commit comments