Skip to content

Commit 2cc76fb

Browse files
authored
ci: consolidate Fern docs publishing (#155)
#### Overview Consolidate Fern documentation validation, preview, cleanup, and publishing into the dedicated Fern Docs workflow. - [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license. - [x] I searched existing issues and open pull requests, and this does not duplicate existing work. #### Details - Remove the reusable `ci_docs.yml` workflow and detach documentation checks from the package CI aggregator. - Update `fern-docs.yml` to use the `fern` environment `FERN_TOKEN` secret for docs publishing. - Generate stable Fern preview deployments using `pull-request-<number>` and delete the matching preview after a PR is merged. - Update contributor, release, and Fern docs to describe the new workflow and secret model. #### Where should the reviewer start? Start with `.github/workflows/fern-docs.yml`, then review `.github/workflows/ci.yaml` to confirm the package CI dependency removal. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Relates to: none ## Summary by CodeRabbit * **Chores** * Removed the separate documentation CI job; docs validation/publishing is now handled independently. * Switched docs publishing to use the environment-scoped FERN_TOKEN. * **Documentation** * PR-based docs previews now generate unique preview IDs and are automatically cleaned up when the PR is merged. * Updated docs and releasing guidance to reflect the new workflow. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NeMo-Relay/pull/155?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) Authors: - Will Killian (https://github.com/willkill07) Approvers: - Bryan Bednarski (https://github.com/bbednarski9) URL: #155
1 parent 2243ec3 commit 2cc76fb

6 files changed

Lines changed: 83 additions & 121 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,6 @@ jobs:
138138
base: ${{ needs.ci_changes.outputs.base }}
139139
default_branch: ${{ github.event.repository.default_branch }}
140140

141-
ci_docs:
142-
name: Documentation
143-
needs: [prepare, ci_changes, ci_check]
144-
uses: ./.github/workflows/ci_docs.yml
145-
if: >-
146-
${{
147-
!cancelled()
148-
&& needs.ci_changes.result == 'success'
149-
&& needs.ci_check.result == 'success'
150-
&& needs.ci_changes.outputs.run_docs == 'true'
151-
}}
152-
permissions:
153-
contents: read
154-
secrets:
155-
DOCS_FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
156-
157141
ci_rust:
158142
name: Rust
159143
needs: [prepare, ci_changes, ci_check]
@@ -226,7 +210,6 @@ jobs:
226210
- prepare
227211
- ci_changes
228212
- ci_check
229-
- ci_docs
230213
- ci_rust
231214
- ci_go
232215
- ci_node
@@ -241,7 +224,6 @@ jobs:
241224
env:
242225
CHANGES_RESULT: ${{ needs.ci_changes.result }}
243226
CHECK_RESULT: ${{ needs.ci_check.result }}
244-
DOCS_RESULT: ${{ needs.ci_docs.result }}
245227
RUST_RESULT: ${{ needs.ci_rust.result }}
246228
GO_RESULT: ${{ needs.ci_go.result }}
247229
NODE_RESULT: ${{ needs.ci_node.result }}
@@ -273,8 +255,6 @@ jobs:
273255
require_success "Changes" "$CHANGES_RESULT"
274256
require_success "Check" "$CHECK_RESULT"
275257
276-
allow_success_or_skipped "Documentation" "$DOCS_RESULT"
277-
278258
if [[ "$publish_packages" == "true" ]]; then
279259
require_success "Rust" "$RUST_RESULT"
280260
require_success "Node.js" "$NODE_RESULT"

.github/workflows/ci_docs.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

.github/workflows/fern-docs.yml

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- 'pull-request/**'
1111
tags:
1212
- '*'
13+
pull_request:
14+
types:
15+
- closed
1316
workflow_dispatch:
1417
inputs:
1518
tag:
@@ -24,7 +27,7 @@ concurrency:
2427
jobs:
2528
changed-files:
2629
name: Detect docs changes
27-
if: ${{ github.ref_type != 'tag' }}
30+
if: ${{ github.ref_type != 'tag' && github.event_name != 'pull_request' }}
2831
runs-on: ubuntu-latest
2932
timeout-minutes: 10
3033
permissions:
@@ -147,7 +150,9 @@ jobs:
147150
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
148151
run: |
149152
set -euo pipefail
150-
if OUTPUT="$("$GITHUB_WORKSPACE/source-checkout/node_modules/.bin/fern" generate --docs --preview 2>&1)"; then
153+
pr_number="${GITHUB_REF_NAME#pull-request/}"
154+
preview_id="pull-request-${pr_number}"
155+
if OUTPUT="$("$GITHUB_WORKSPACE/source-checkout/node_modules/.bin/fern" generate --docs --preview --id "$preview_id" 2>&1)"; then
151156
fern_exit=0
152157
else
153158
fern_exit=$?
@@ -172,7 +177,59 @@ jobs:
172177
gh pr comment "https://github.com/${{ github.repository }}/pull/${pr_number}" \
173178
--edit-last \
174179
--create-if-none \
175-
--body "Fern docs preview: ${{ steps.preview.outputs.url }}/dev"
180+
--body "Fern docs preview: ${{ steps.preview.outputs.url }}"
181+
182+
cleanup-preview-docs:
183+
name: Clean up docs preview
184+
if: >-
185+
${{
186+
github.event_name == 'pull_request'
187+
&& github.event.action == 'closed'
188+
&& github.event.pull_request.merged == true
189+
}}
190+
runs-on: ubuntu-latest
191+
environment: fern
192+
timeout-minutes: 10
193+
permissions:
194+
contents: read
195+
env:
196+
UV_PYTHON_DOWNLOADS: never
197+
steps:
198+
- name: Checkout source branch
199+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
200+
with:
201+
ref: ${{ github.event.pull_request.base.ref }}
202+
path: source-checkout
203+
fetch-depth: 1
204+
persist-credentials: false
205+
206+
- name: Load CI tool versions
207+
id: ci-config
208+
uses: ./source-checkout/.github/actions/load-ci-tool-versions
209+
210+
- name: Setup Node.js
211+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
212+
with:
213+
node-version: ${{ steps.ci-config.outputs.node_version }}
214+
package-manager-cache: false
215+
216+
- name: Install Fern CLI
217+
working-directory: source-checkout
218+
run: |
219+
set -euo pipefail
220+
npm ci --ignore-scripts
221+
222+
- name: Delete preview deployment
223+
working-directory: source-checkout/fern
224+
env:
225+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
226+
PR_NUMBER: ${{ github.event.pull_request.number }}
227+
run: |
228+
set -euo pipefail
229+
preview_id="pull-request-${PR_NUMBER}"
230+
echo "Deleting Fern docs preview: ${preview_id}"
231+
"$GITHUB_WORKSPACE/source-checkout/node_modules/.bin/fern" docs preview delete --id "$preview_id" \
232+
|| echo "Fern preview deletion returned non-zero; it may already be deleted."
176233
177234
publish-dev-docs:
178235
name: Publish dev docs
@@ -186,6 +243,7 @@ jobs:
186243
)
187244
}}
188245
runs-on: ubuntu-latest
246+
environment: fern
189247
timeout-minutes: 60
190248
permissions:
191249
contents: write
@@ -253,7 +311,7 @@ jobs:
253311
working-directory: source-checkout
254312
env:
255313
NEMO_RELAY_DOCS_DEPS_READY: "1"
256-
FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
314+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
257315
run: just docs
258316

259317
- name: Checkout docs website branch
@@ -302,7 +360,7 @@ jobs:
302360
if: ${{ steps.changes.outputs.has_changes == 'true' }}
303361
working-directory: docs-checkout/fern
304362
env:
305-
FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
363+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
306364
run: |
307365
"$GITHUB_WORKSPACE/source-checkout/node_modules/.bin/fern" generate --docs
308366
@@ -314,6 +372,7 @@ jobs:
314372
|| (github.event_name == 'workflow_dispatch' && inputs.tag != '' && inputs.tag != null)
315373
}}
316374
runs-on: ubuntu-latest
375+
environment: fern
317376
timeout-minutes: 30
318377
permissions:
319378
contents: write
@@ -403,6 +462,6 @@ jobs:
403462
- name: Publish docs
404463
working-directory: docs-checkout/fern
405464
env:
406-
FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
465+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
407466
run: |
408467
"$GITHUB_WORKSPACE/source-checkout/node_modules/.bin/fern" generate --docs

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ The workflow boundary is split intentionally:
254254

255255
- The language-specific reusable workflows produce publishable package artifacts
256256
after their tests pass.
257-
- [`.github/workflows/ci_docs.yml`](.github/workflows/ci_docs.yml) validates the
258-
Fern documentation.
257+
- [`.github/workflows/fern-docs.yml`](.github/workflows/fern-docs.yml) validates
258+
and publishes Fern documentation independently from package CI.
259259
- [`.github/workflows/ci.yaml`](.github/workflows/ci.yaml) owns all crates.io,
260260
PyPI, and npm publication decisions and credentials.
261261
- This layout also satisfies the official `pypa/gh-action-pypi-publish`

docs/contribute/testing-and-docs.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,17 @@ on `main` in `docs/` and `fern/`. The generated Fern content on
104104
`.gitignore`, `README.md`, and `.github/workflows/publish-fern-docs.yml` are
105105
branch-local maintenance files and can be updated directly on `docs-website`.
106106

107-
The Fern workflow uses `DOCS_FERN_TOKEN` as the repository secret. Pull-request
108-
branches under `pull-request/**` get Fern previews when docs change. Pushes to
109-
`main` sync the generated `fern/pages-dev/` layout to `docs-website` and publish
110-
the dev docs. Raw SemVer tags such as `0.1.0`, `0.1.0-beta.1`, and `0.1.0-rc.1`
111-
create public docs versions displayed with a leading `v`. Prerelease indicators
112-
are stripped from the public docs version path, so `0.1.0-beta.1`,
113-
`0.1.0-rc.1`, and `0.1.0` all target `v0.1.0`. Stable tags use
114-
`availability: stable` and update the default `Latest` version. Beta and
115-
release-candidate tags use `availability: beta`, replace the same base version
116-
snapshot, and do not update `Latest`. Alpha tags are not published.
107+
The Fern workflow uses the `FERN_TOKEN` GitHub environment secret from the
108+
`fern` environment. Pull-request branches under `pull-request/**` get Fern
109+
previews when docs change, and merged pull requests clean up their preview
110+
deployment. Pushes to `main` sync the generated `fern/pages-dev/` layout to
111+
`docs-website` and publish the dev docs. Raw SemVer tags such as `0.1.0`,
112+
`0.1.0-beta.1`, and `0.1.0-rc.1` create public docs versions displayed with a
113+
leading `v`. Prerelease indicators are stripped from the public docs version
114+
path, so `0.1.0-beta.1`, `0.1.0-rc.1`, and `0.1.0` all target `v0.1.0`. Stable
115+
tags use `availability: stable` and update the default `Latest` version. Beta
116+
and release-candidate tags use `availability: beta`, replace the same base
117+
version snapshot, and do not update `Latest`. Alpha tags are not published.
117118

118119
The branch sync and version snapshot logic lives in
119120
`scripts/docs/sync_fern_docs_branch.py`.

fern/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ layout can be validated outside GitHub Actions.
4646

4747
## Publishing
4848

49-
The Fern publish workflow uses the GitHub secret `DOCS_FERN_TOKEN` and passes it
50-
to the Fern CLI as `FERN_TOKEN`.
49+
The Fern publish workflow uses the `FERN_TOKEN` GitHub environment secret from
50+
the `fern` environment and passes it to the Fern CLI as `FERN_TOKEN`.
5151

52-
- Pushes to `pull-request/**` that affect docs generate a Fern preview and add
53-
the preview URL to the pull request.
52+
- Pushes to `pull-request/**` that affect docs generate a stable Fern preview
53+
and add the preview URL to the pull request. When the pull request is merged,
54+
the workflow deletes the matching preview deployment.
5455
- Pushes to `main` that affect docs regenerate API reference pages, sync
5556
`docs-website`, and publish the dev docs.
5657
- Raw SemVer tags such as `0.1.0`, `0.1.0-beta.1`, and `0.1.0-rc.1` create or

0 commit comments

Comments
 (0)