diff --git a/.github/workflows/docs-deploy-preview.yaml b/.github/workflows/docs-deploy-preview.yaml deleted file mode 100644 index 228884d03..000000000 --- a/.github/workflows/docs-deploy-preview.yaml +++ /dev/null @@ -1,92 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# -# Deploy PR docs preview to GitHub Pages after manual approval. -# -# Triggered by the "Build & deploy docs" workflow completing on a pull request. -# Uses a "docs-preview" environment with required reviewers so that someone with -# write access must approve before the deploy runs — this lets fork PRs get -# previews without giving their GITHUB_TOKEN write access to the base repo. -# -# Setup: create a "docs-preview" environment in repo Settings → Environments, -# then add required reviewers (anyone with write access to the repo). - -name: Deploy docs PR preview - -on: - workflow_run: - workflows: ["Build & deploy docs"] - types: [completed] - -concurrency: - group: >- - deploy-preview-${{ github.event.workflow_run.head_repository.id }}-${{ github.event.workflow_run.head_branch }} - cancel-in-progress: true - -jobs: - deploy-preview: - name: Deploy PR preview - runs-on: ubuntu-latest - if: >- - github.event.workflow_run.event == 'pull_request' - && github.event.workflow_run.conclusion == 'success' - environment: docs-preview - permissions: - actions: read # download artifacts from the triggering run - contents: write # push to gh-pages - steps: - - name: Download PR metadata - uses: actions/download-artifact@v7 - with: - name: pr-metadata - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Read PR number - id: pr - run: echo "number=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT" - - - name: Download docs artifact - uses: actions/download-artifact@v7 - with: - name: docs-html - path: ./docs/build - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Download web app artifact - uses: actions/download-artifact@v7 - with: - name: webapp - path: ./webapp - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Place web app under subpath - run: | - mkdir -p ./docs/build/current/client - cp -r ./webapp/. ./docs/build/current/client/ - - - name: Deploy PR preview to gh-pages - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/build/current - destination_dir: preview/pr-${{ steps.pr.outputs.number }} - keep_files: true - - - name: Add preview URL to workflow summary - run: | - base="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/preview/pr-${{ steps.pr.outputs.number }}/" - client_url="${base}client/" - { - echo "## Docs preview" - echo - echo "Built docs for this PR are available at:" - echo - echo "**${base}**" - echo - echo "Teleop web app (subpath \`/client/\`): **${client_url}**" - echo - echo "(It may take a minute to appear after the workflow completes.)" - } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index e48a187ac..88caefe61 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -2,9 +2,8 @@ # SPDX-License-Identifier: Apache-2.0 # # Build docs and Teleop web app, then deploy to GitHub Pages. -# - Push to main/release (canonical repo): build + deploy docs at site root, web app at /client/. -# - Pull requests: build only; preview deploy is handled by docs-deploy-preview.yaml -# via workflow_run (runs in base-repo context so fork PRs get write access). +# - Push to main (canonical repo): deploy docs at site root, web app at /client/. +# - Pull requests: deploy to preview/pr-/ (docs at root of preview, app at preview/pr-/client/). # # PR: docs always built; web client (npm) built with public SDK for all, or private SDK only for allowlisted authors. # Main/release (push): key used → private NGC for SDK. @@ -96,17 +95,6 @@ jobs: name: docs-html path: ./docs/build - - name: Save PR number - if: github.event_name == 'pull_request' - run: echo "${{ github.event.pull_request.number }}" > pr-number.txt - - - name: Upload PR metadata - if: github.event_name == 'pull_request' - uses: actions/upload-artifact@v6 - with: - name: pr-metadata - path: pr-number.txt - build-app: name: Build Teleop Web App runs-on: ubuntu-latest @@ -163,9 +151,7 @@ jobs: name: Deploy docs runs-on: ubuntu-latest needs: [check-repo, build-docs, build-app] - if: >- - needs.check-repo.outputs.is-canonical-repo == 'true' - && needs.check-repo.outputs.is-deploy-branch == 'true' + if: needs.check-repo.outputs.is-canonical-repo == 'true' && (needs.check-repo.outputs.is-deploy-branch == 'true' || github.event_name == 'pull_request') permissions: contents: write # push to gh-pages steps: @@ -183,12 +169,44 @@ jobs: - name: Place web app under subpath run: | - mkdir -p ./docs/build/client - cp -r ./webapp/. ./docs/build/client/ + if [ "${{ github.event_name }}" = 'pull_request' ]; then + CLIENT_DIR=./docs/build/current/client + else + CLIENT_DIR=./docs/build/client + fi + mkdir -p "$CLIENT_DIR" + cp -r ./webapp/. "$CLIENT_DIR/" - - name: Deploy to gh-pages - uses: peaceiris/actions-gh-pages@v4 + - name: Deploy to gh-pages (main branch) + if: github.event_name == 'push' && needs.check-repo.outputs.is-deploy-branch == 'true' + uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/build keep_files: true + + - name: Deploy PR preview to gh-pages + if: github.event_name == 'pull_request' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/build/current + destination_dir: preview/pr-${{ github.event.pull_request.number }} + keep_files: true + + - name: Add preview URL to workflow summary + if: github.event_name == 'pull_request' + run: | + base="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/preview/pr-${{ github.event.pull_request.number }}/" + client_url="${base}client/" + { + echo "## Docs preview" + echo + echo "Built docs for this PR are available at:" + echo + echo "**${base}**" + echo + echo "Teleop web app (subpath \`/client/\`): **${client_url}**" + echo + echo "(It may take a minute to appear after the workflow completes.)" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/docs/source/getting_started/contributing.rst b/docs/source/getting_started/contributing.rst index d59c19a3b..8b7de74e4 100644 --- a/docs/source/getting_started/contributing.rst +++ b/docs/source/getting_started/contributing.rst @@ -9,3 +9,47 @@ We welcome contributions. Please see the repository's `CONTRIBUTING.md / + +The preview link is also added to the workflow run's *Summary* tab. It is +refreshed on each push to the PR. Previews accumulate on the ``gh-pages`` +branch under ``preview/``; maintainers can clear them by manually running the +``Cleanup docs PR previews`` workflow from the Actions tab. + +.. note:: + + Pull requests opened **from a fork** do not get an automatic preview because + the workflow's ``GITHUB_TOKEN`` is read-only in that context and cannot push + to ``gh-pages``. If you have write access to ``NVIDIA/IsaacTeleop``, push + your branch there directly to get a preview; otherwise, attach screenshots of + your local build to the PR description.