test: migrate remaining test loops (#9402) #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Docs / Publish Staging | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "docs/**" | |
| - "fern/**" | |
| - "package.json" | |
| - "package-lock.json" | |
| - "scripts/generate-starter-prompt.mts" | |
| - "scripts/sync-agent-variant-docs.mts" | |
| - ".github/workflows/docs-publish-staging.yaml" | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: docs-publish-staging | |
| cancel-in-progress: false | |
| env: | |
| FERN_STAGING_INSTANCE: nvidia-nemoclaw-staging.docs.buildwithfern.com/nemoclaw | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| environment: docs-staging | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: "24" | |
| - name: Install docs dependencies | |
| run: npm ci --ignore-scripts | |
| - name: Prepare and validate Fern docs | |
| run: | | |
| npm run docs:prepare | |
| npm run docs:validate | |
| - name: Publish staging docs | |
| env: | |
| FERN_TOKEN: ${{ secrets.FERN_TOKEN }} | |
| run: | | |
| FERN_VERSION=$(node -p "require('./fern/fern.config.json').version") | |
| cd fern | |
| npx --yes "fern-api@${FERN_VERSION}" generate --docs --instance "$FERN_STAGING_INSTANCE" | |
| delete-preview: | |
| runs-on: ubuntu-latest | |
| needs: publish | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| steps: | |
| - name: Find merged PR previews | |
| id: previews | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} | |
| COMMIT_SHA: ${{ github.sha }} | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "preview_ids<<EOF" | |
| gh api "repos/${GH_REPO}/commits/${COMMIT_SHA}/pulls" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| --jq '.[] | "pr-\(.number)"' | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| mapfile -t pr_numbers < <( | |
| gh api "repos/${GH_REPO}/commits/${COMMIT_SHA}/pulls" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| --jq '.[].number' | |
| ) | |
| if [ "${#pr_numbers[@]}" -eq 0 ]; then | |
| echo "has_previews=false" >> "$GITHUB_OUTPUT" | |
| echo "::notice::No PR associated with ${COMMIT_SHA}; no Fern previews to delete." | |
| exit 0 | |
| fi | |
| echo "has_previews=true" >> "$GITHUB_OUTPUT" | |
| printf 'Found Fern preview IDs to delete: ' | |
| printf 'pr-%s ' "${pr_numbers[@]}" | |
| printf '\n' | |
| - name: Checkout repository | |
| if: ${{ steps.previews.outputs.has_previews == 'true' }} | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| if: ${{ steps.previews.outputs.has_previews == 'true' }} | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: "24" | |
| - name: Delete Fern previews | |
| if: ${{ steps.previews.outputs.has_previews == 'true' }} | |
| env: | |
| FERN_TOKEN: ${{ secrets.FERN_TOKEN }} | |
| PREVIEW_IDS: ${{ steps.previews.outputs.preview_ids }} | |
| run: | | |
| set -euo pipefail | |
| FERN_VERSION=$(node -p "require('./fern/fern.config.json').version") | |
| FERN_ORG=$(node -p "require('./fern/fern.config.json').organization") | |
| INSTANCE_PATH="${FERN_STAGING_INSTANCE#*/}" | |
| if [[ "$INSTANCE_PATH" == "$FERN_STAGING_INSTANCE" ]]; then | |
| INSTANCE_PATH="" | |
| else | |
| INSTANCE_PATH="/${INSTANCE_PATH}" | |
| fi | |
| cd fern | |
| while IFS= read -r preview_id; do | |
| if [ -z "$preview_id" ]; then | |
| continue | |
| fi | |
| preview_url="https://${FERN_ORG}-preview-${preview_id}.docs.buildwithfern.com${INSTANCE_PATH}" | |
| if ! delete_output=$(npx --yes "fern-api@${FERN_VERSION}" docs preview delete "$preview_url" 2>&1); then | |
| if grep -Fxq "Domain not registered" <<< "$delete_output"; then | |
| echo "::notice::Fern preview ${preview_id} does not exist." | |
| continue | |
| fi | |
| printf '%s\n' "$delete_output" >&2 | |
| exit 1 | |
| fi | |
| printf '%s\n' "$delete_output" | |
| echo "Deleted Fern preview ${preview_id}." | |
| done <<< "$PREVIEW_IDS" |