diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 6520e3d..9633bfe 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -60,6 +60,16 @@ on: default: false required: false type: boolean + upload-artifact: + description: "Upload the built documentation (`docs/build`) as a workflow artifact named `docs-artifact` when the build succeeds, so it can be downloaded and inspected, e.g. for pull requests from forks, which cannot deploy a preview" + default: false + required: false + type: boolean + artifact-retention-days: + description: "Number of days to keep the documentation artifact uploaded by `upload-artifact` (0 uses the repository default)" + default: 3 + required: false + type: number jobs: tests: @@ -110,6 +120,20 @@ jobs: DOCUMENTER_KEY: ${{ env.CAN_DEPLOY_DOCS == 'true' && inputs.use-documenter-key && (inputs.documenter-key || secrets.DOCUMENTER_KEY) || '' }} run: ${{ inputs.debug-documenter && 'JULIA_DEBUG="Documenter"' || '' }} julia --color=yes --project=docs/ ${{ inputs.coverage && '--code-coverage=user' || '' }} docs/make.jl + - name: "Upload Documentation as Artifact" + # Like every step without a status function in its `if:`, this runs only when the + # steps before it succeeded, so a failed build uploads nothing. Pull requests from + # forks cannot deploy a preview (see CAN_DEPLOY_DOCS), so this artifact is the only + # way to inspect their rendered documentation. + uses: actions/upload-artifact@v7 + if: "${{ inputs.upload-artifact }}" + with: + name: "docs-artifact" + path: "docs/build" + retention-days: "${{ inputs.artifact-retention-days }}" + compression-level: 9 + overwrite: true + - name: "Filter coverage directories to those that exist" # julia-processcoverage hard-errors on directories that don't exist # (the "src,ext" default includes ext even for packages without diff --git a/README.md b/README.md index 8bace7b..39327e0 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,8 @@ documentation (and runs doctests, with coverage). | `coverage` | boolean | `true` | Collect doctest coverage. | | `coverage-directories` | string | `"src,ext"` | Coverage dirs. | | `continue-on-error` | boolean | — | Don't fail the run if the job fails. | +| `upload-artifact` | boolean | `false` | Upload `docs/build` as the workflow artifact `docs-artifact` when the build succeeds. | +| `artifact-retention-days` | number | `3` | Days to keep that artifact (`0` = repository default). | ```yaml jobs: @@ -306,6 +308,11 @@ jobs: secrets: "inherit" ``` +Pull requests from forks can't deploy a documentation preview, so the job +only reports whether the docs build. To let reviewers download and inspect +the rendered docs, set `upload-artifact: true`; the site then appears as +`docs-artifact` under the run's **Artifacts**. + ### `runic.yml` Checks formatting with [Runic](https://github.com/fredrikekre/Runic.jl) — the