mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-11 04:30:53 +08:00
* docs: align page file names and nav labels with published URLs Signed-off-by: Johnny Greco <jogreco@nvidia.com> * docs: redirect moved dev pages and fix agent guide redirects Signed-off-by: Johnny Greco <jogreco@nvidia.com> * ci(docs): check that page URLs match their file paths Signed-off-by: Johnny Greco <jogreco@nvidia.com> * fix(docs): align navigation checks with repo conventions Signed-off-by: Johnny Greco <jogreco@nvidia.com> * docs: omit historical redirect aliases Signed-off-by: Johnny Greco <jogreco@nvidia.com> * fix(docs): preserve published overview and TypeScript URLs Signed-off-by: Johnny Greco <jogreco@nvidia.com> * fix(docs): redirect unversioned overview and TypeScript URLs Signed-off-by: Johnny Greco <jogreco@nvidia.com> --------- Signed-off-by: Johnny Greco <jogreco@nvidia.com>
105 lines
3.5 KiB
YAML
105 lines
3.5 KiB
YAML
name: Branch Docs Preview
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "docs/**"
|
|
- "fern/**"
|
|
- "mise.toml"
|
|
- "tasks/docs.toml"
|
|
- "tasks/test.toml"
|
|
- "tasks/scripts/check_docs_nav.py"
|
|
- "tasks/scripts/check_docs_nav_test.py"
|
|
- ".github/workflows/branch-docs.yml"
|
|
- ".github/workflows/release-tag.yml"
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
preview:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- name: Check Fern preview availability
|
|
id: fern-preview
|
|
env:
|
|
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
|
|
run: |
|
|
if [ -n "$FERN_TOKEN" ]; then
|
|
echo "enabled=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "enabled=false" >> "$GITHUB_OUTPUT"
|
|
echo "::notice::Skipping Fern docs preview because FERN_TOKEN is unavailable. This is expected for fork PRs and repos without Fern preview credentials configured."
|
|
fi
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
with:
|
|
node-version: "24"
|
|
|
|
- name: Install Fern CLI
|
|
run: |
|
|
FERN_VERSION=$(node -p "require('./fern/fern.config.json').version")
|
|
npm install -g "fern-api@${FERN_VERSION}"
|
|
|
|
- name: Validate docs
|
|
working-directory: ./fern
|
|
run: fern check
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@ae62891fec2bb8e7d6c99fc78c9fec3a63790f8d # v10.0.0
|
|
with:
|
|
version: "0.10.12"
|
|
python-version: "3.13"
|
|
|
|
- name: Test docs navigation check
|
|
run: uv run --no-project --with pytest --with pytest-asyncio --with pyyaml pytest tasks/scripts/check_docs_nav_test.py
|
|
|
|
- name: Check docs navigation matches file paths
|
|
run: uv run tasks/scripts/check_docs_nav.py
|
|
|
|
- name: Generate preview URL
|
|
if: ${{ steps.fern-preview.outputs.enabled == 'true' }}
|
|
id: generate-docs
|
|
env:
|
|
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
|
|
PREVIEW_ID: pr-${{ github.event.pull_request.number }}
|
|
working-directory: ./fern
|
|
run: |
|
|
OUTPUT=$(fern generate --docs --preview --id "$PREVIEW_ID" 2>&1)
|
|
echo "$OUTPUT"
|
|
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
|
|
if [ -z "$URL" ]; then
|
|
echo "::error::Failed to generate preview URL. See fern output above."
|
|
exit 1
|
|
fi
|
|
echo "preview_url=$URL" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Post or update PR comment
|
|
if: ${{ steps.fern-preview.outputs.enabled == 'true' }}
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
PREVIEW_URL: ${{ steps.generate-docs.outputs.preview_url }}
|
|
run: |
|
|
BODY=":herb: **Preview your docs:** <${PREVIEW_URL}>"
|
|
MARKER="<!-- preview-docs -->"
|
|
BODY="${BODY}
|
|
|
|
${MARKER}"
|
|
|
|
COMMENT_ID=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \
|
|
--jq ".[] | select(.body | contains(\"${MARKER}\")) | .id" | head -1)
|
|
|
|
if [ -n "$COMMENT_ID" ]; then
|
|
gh api "repos/${{ github.repository }}/issues/comments/${COMMENT_ID}" \
|
|
-X PATCH -f body="$BODY"
|
|
else
|
|
gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \
|
|
-f body="$BODY"
|
|
fi
|