Skip to content

EXP-2127: Add per-PR preview deployments via GitHub Pages - #1872

Merged
pmckinney-codat merged 3 commits into
mainfrom
exp-2127-pr-preview-deployments
Aug 5, 2026
Merged

EXP-2127: Add per-PR preview deployments via GitHub Pages#1872
pmckinney-codat merged 3 commits into
mainfrom
exp-2127-pr-preview-deployments

Conversation

@pmckinney-codat

@pmckinney-codat pmckinney-codat commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Adds per-PR preview deployments so reviewers can browse the rendered site before it merges. Jira: EXP-2127 (under EXP-1595).

What this does

  • New deploy-preview job in the PR workflow: builds the site with BASE_URL=/codat-docs/pr-preview/pr-<number> and publishes it to the gh-pages branch via rossjrw/pr-preview-action, which posts a sticky comment on the PR with the preview URL and updates it on every push.
  • The preview is torn down automatically when the PR closes (the workflow now also triggers on closed; the build/link-check job skips that event).
  • BASE_URL in docusaurus.config.js is now env-driven. Production/integration builds are unaffected — with the env var unset it resolves to the current baseUrl of /.
  • Fork PRs skip the preview job (no secrets, read-only GITHUB_TOKEN).

Setup status

  • gh-pages branch initialised (root .nojekyll + placeholder index).
  • ✅ GitHub Pages enabled on the repo, serving gh-pages at https://codatio.github.io/codat-docs/ (required a one-off org-policy change to allow public Pages creation).
  • This PR should demonstrate the feature on itself — look for the preview sticky comment below.

Notes / tradeoffs

  • Previews are public to anyone with the URL (same exposure as any preview host for a public repo).
  • The gh-pages branch accumulates history (image-heavy build output); an occasional force-reset keeps it in check.
  • EXP-1595's pattern of record has PR previews on Azure Static Web Apps long-term; this is a zero-infra interim and is easy to unwind (delete the job + gh-pages).

🤖 Generated with Claude Code

Add a deploy-preview job to the PR workflow that publishes the built
site to the gh-pages branch under pr-preview/pr-<number>/ using
rossjrw/pr-preview-action, posts a sticky comment with the preview URL,
and tears the preview down when the PR closes.

BASE_URL in docusaurus.config.js becomes env-driven so preview builds
can target the Pages subpath; production builds are unaffected (env var
unset resolves to the current baseUrl of "/").

Fork PRs are skipped: they get neither secrets nor a writable
GITHUB_TOKEN, and already cannot build due to ADO npm feed auth.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-05 08:19 UTC

Raw JSX attributes bypass Docusaurus baseUrl handling, so absolute
/img, /logos, and /oas paths broke on the PR preview (served from
/codat-docs/pr-preview/pr-<n>/ rather than /):

- MDXComponents/Img: apply useBaseUrl to src, fixing all raw <img>
  tags in MDX content centrally (51 across 28 files)
- Api: apply useBaseUrl to the OAS spec URL, fixing all 21 API
  reference pages centrally (Stoplight fetched /oas/... from the
  domain root, so specs 404'd on the preview)
- Cards, Products, ClientLibraries: withBaseUrl on card images and
  internal links
- support page, BlogSidebar: raw <a href="/..."> swapped for
  Docusaurus Link

Production output is unchanged: with baseUrl "/", withBaseUrl is a
no-op (every path already starts with "/"), and external URLs and
bundled assets pass through untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…h deploys

Literal <img> JSX written inside Markdown/MDX content bypasses the
MDXComponents mapping entirely (MDX v3 semantics), so the previous
MDXImg fix never saw it. Add a rehype plugin that rewrites absolute
img srcs at compile time, wired into the docs and blog pipelines; it
no-ops in production where baseUrl is "/".

Also make PageHeader (frontmatter banner_image/banner_icon) and
Clients (client logo paths) baseUrl-aware, the remaining components
that received absolute asset paths as props.

A clean subpath build now has zero unprefixed /img and /logos srcs
across the output (was 127).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Link check results:

[]

@pmckinney-codat
pmckinney-codat merged commit 5363d00 into main Aug 5, 2026
6 checks passed
@pmckinney-codat
pmckinney-codat deleted the exp-2127-pr-preview-deployments branch August 5, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants