ci: add Docs PR Preview workflow (build gate + per-PR preview) - #603
ci: add Docs PR Preview workflow (build gate + per-PR preview)#603rajivml wants to merge 1 commit into
Conversation
Builds the docs site on every PR that touches docs/ or mkdocs.yml — the build doubles as a CI gate so a broken docs change cannot merge — and publishes a per-PR preview to gh-pages under /pr-preview/pr-<N>/ for same-repo PRs, torn down when the PR closes. Uses pull_request (not pull_request_target), gates the write-scoped deploy to same-repo PRs, interpolates no untrusted event data into run steps, and pins the third-party action to a commit SHA.
|
| permissions: | ||
| contents: write # publish the preview to the gh-pages branch | ||
| pull-requests: write # post/update the preview link comment |
There was a problem hiding this comment.
Setting contents: write and pull-requests: write at workflow level means every build step — npm ci, npm run docs:api, mkdocs build — executes with repository write access. For same-repo PRs, a supply-chain compromise in an npm dependency could abuse this token.
The canonical hardening for pull_request workflows is to split into two jobs so the untrusted build code runs read-only:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# ... all build steps ...
- uses: actions/upload-artifact@v4
with:
name: site
path: site/
deploy-preview:
needs: build
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: site
path: site/
- uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9
with:
source-dir: site
preview-branch: gh-pages
umbrella-dir: pr-preview
action: autoThis way write credentials are never present in the process tree that runs untrusted build code. For fork PRs GitHub overrides the token to read-only anyway, so the real exposure is same-repo PRs only — but that's still worth minimising.
| paths: | ||
| - "docs/**" | ||
| - "mkdocs.yml" | ||
| - "docs/requirements.txt" |
There was a problem hiding this comment.
docs/requirements.txt is already matched by the docs/** glob above it, so this entry is redundant.
| - "docs/requirements.txt" |
Review summaryTwo findings from this run:
|
|
Folded into #602 — the Docs PR Preview workflow is now part of that PR so both changes review together. |
What
Adds a Docs PR Preview workflow (
.github/workflows/docs-pr-preview.yml) that:docs/**ormkdocs.yml(full pipeline:npm ci→docs:api→mkdocs build). The build doubles as a CI gate — a broken docs change now fails a check instead of shipping on the next scheduled deploy.https://uipath.github.io/uipath-typescript/pr-preview/pr-<N>/for same-repo PRs, and tears it down when the PR closes — so reviewers can see rendered docs changes before merge.Why
Today
docs.ymlonly builds/deploys on a Monday schedule and manual dispatch, straight to production. Nothing validates or previews docs on a PR, so contributors can't see how a change will look and a broken build isn't caught until deploy. This closes that gap.Security
pull_request(notpull_request_target) — fork PRs run with a read-only token and no secrets.run:step — no command-injection surface.One-time setup after merge
Repo Settings → Actions → General → Workflow permissions → Read and write (so the preview can publish to
gh-pages). Pages already servesgh-pages, so no Pages change is needed.Complements #602 (which adds the Template Gallery docs page).
🤖 Generated with Claude Code