Files
Pete MacKinnonandClaude Sonnet 4.6 00cd031220 ci: add Fern Docs CI required gate (#1279)
* ci: add Fern Docs CI required gate

Add a required-merge-gate workflow (fern-docs-ci.yml) that runs
python3 tools/check-docs-mdx, fern check, and fern docs md check on
every pull request that touches docs or fern/. The gate carries no
secrets and requires no FERN_TOKEN.

Also drop the Fern CLI version pin from api-docs.yml; both workflows
now use fern-api@latest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pete MacKinnon <mackinnon.pd@gmail.com>

* ci(fern-docs-ci): always run, skip expensive steps when no docs changed

Without a required-check-aware path filter the workflow never posts a
status on non-docs PRs, which blocks merge if the check is required.
Remove the trigger-level paths: filter and use a changed-files step
inside the job to skip the Fern steps when no relevant paths changed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pete MacKinnon <mackinnon.pd@gmail.com>

* ci: add Fern Docs preview build and comment workflows

Adds the two-workflow split for PR previews per the fern-scripts skill:
- fern-docs-preview-build.yml: collects fern/ and docs/ sources in the
  PR context (no secrets), uploads as artifact
- fern-docs-preview-comment.yml: triggered by workflow_run, generates a
  Fern preview with DOCS_FERN_TOKEN and posts a 🌿 comment on the PR

Requires DOCS_FERN_TOKEN organization secret. Note: api-docs.yml uses
FERN_TOKEN; both need the same underlying Fern org token.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pete MacKinnon <mackinnon.pd@gmail.com>

* ci(fern-docs-preview): use FERN_TOKEN to match org convention

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pete MacKinnon <mackinnon.pd@gmail.com>

* ci(fern-docs-preview): fix preview ID collision and URL extraction

Use pr-{number} as the Fern preview --id instead of HEAD_REF, matching
the api-docs.yml convention and avoiding collisions between PRs that share
a branch name. Switch URL extraction from a look-behind regex requiring a
trailing paren to a simpler https:// grep matching Fern's actual output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pete MacKinnon <mackinnon.pd@gmail.com>

* ci(fern-docs-preview): harden comment workflow against artifact injection

- Validate pr_number is numeric before writing to GITHUB_OUTPUT
- Checkout fern/ from the base branch and replace the artifact copy so
  npx never runs in PR-controlled code (prevents .npmrc / package.json
  injection that could exfiltrate FERN_TOKEN)
- Validate preview URL is on buildwithfern.com before sending FERN_TOKEN
  in the page-links curl call
- Drop FERN_TOKEN from page-links env; the get-slug-for-file API call
  does not require it

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pete MacKinnon <mackinnon.pd@gmail.com>

---------

Signed-off-by: Pete MacKinnon <mackinnon.pd@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-10-09 12:43:23 -04:00
..