simplify #70
Workflow file for this run
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) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # Workflow 1 of 2 for Fern doc previews. | |
| # | |
| # Collects the fern/ and docs/ sources plus PR metadata from the PR branch and | |
| # uploads them as an artifact. Both directories are needed because | |
| # fern/docs.yml references ../docs/index.yml; omitting docs/ causes | |
| # `fern generate --docs` to fail in the companion workflow. No secrets are | |
| # used here. | |
| # | |
| # Triggers on push to pull-request/<n> branches (NVIDIA copy-PR-bot pattern). | |
| # On push events github.head_ref and github.event.pull_request.number are | |
| # empty — PR number and branch name are extracted from github.ref_name instead. | |
| # | |
| # The companion workflow (fern-docs-preview-comment.yml) picks up the artifact, | |
| # builds the preview with DOCS_FERN_TOKEN, and posts the PR comment. | |
| name: "Preview Fern Docs: Build" | |
| on: | |
| push: | |
| branches: | |
| - "pull-request/[0-9]+" | |
| paths: | |
| - 'docs/**' | |
| - 'fern/**' | |
| - '.github/workflows/fern-docs-preview-build.yml' | |
| permissions: | |
| contents: read | |
| jobs: | |
| collect: | |
| runs-on: linux-amd64-cpu8 | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Save PR metadata | |
| env: | |
| BRANCH_NAME: ${{ github.ref_name }} | |
| run: | | |
| mkdir -p preview-metadata | |
| echo "${BRANCH_NAME#pull-request/}" > preview-metadata/pr_number | |
| echo "$BRANCH_NAME" > preview-metadata/head_ref | |
| git diff --name-only "origin/main...HEAD" -- '*.md' > preview-metadata/changed_md_files 2>/dev/null || true | |
| - name: Checkout frozen version content | |
| run: | | |
| set -eo pipefail | |
| for version_file in fern/versions/v*.yml; do | |
| [ -f "$version_file" ] || continue | |
| version=$(basename "$version_file" .yml) | |
| if git show-ref --verify --quiet "refs/tags/${version}"; then | |
| mkdir -p "fern/versions/${version}-content" | |
| git archive "refs/tags/${version}" -- docs/ | tar -x --strip-components=1 -C "fern/versions/${version}-content" | |
| find "fern/versions/${version}-content" -name '*.md' -print0 | xargs -0 -r sed -i \ | |
| -e 's/{/\\{/g' \ | |
| -e 's/}/\\}/g' \ | |
| -e 's/</\</g' | |
| for subdir in "fern/versions/${version}-content"/*/; do | |
| if [ ! -d "${subdir}assets" ] && [ -d "fern/versions/${version}-content/assets" ]; then | |
| ln -sf ../assets "${subdir}assets" | |
| fi | |
| done | |
| echo "Extracted docs from $version" | |
| else | |
| echo "::warning::Tag $version not found — skipping content checkout" | |
| fi | |
| done | |
| - name: Upload fern sources and metadata | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: fern-preview | |
| path: | | |
| fern/ | |
| docs/ | |
| preview-metadata/ | |
| retention-days: 1 |