Docs PR Preview Deploy #2
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 | |
| # Step 2 of 2: Deploy (or clean up) the docs preview built by docs-preview-pr.yaml. | |
| # Runs via workflow_run so it always has write access to gh-pages. | |
| # Only deploys previews for same-repo PRs to prevent fork PRs from | |
| # publishing arbitrary content to the GitHub Pages domain. | |
| name: Docs PR Preview Deploy | |
| on: | |
| workflow_run: | |
| workflows: ["Docs PR Preview"] | |
| types: [completed] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: read | |
| jobs: | |
| deploy: | |
| if: github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| # Checkout first so subsequent artifact downloads are not clobbered. | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Download PR metadata | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| with: | |
| name: docs-preview-metadata | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Read PR metadata | |
| id: meta | |
| run: | | |
| echo "pr-number=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT" | |
| if [ -f pr-action.txt ]; then | |
| echo "action=$(cat pr-action.txt)" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "action=deploy" >> "$GITHUB_OUTPUT" | |
| fi | |
| if [ -f same-repo.txt ]; then | |
| echo "same-repo=$(cat same-repo.txt)" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "same-repo=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Skip fork PRs | |
| if: steps.meta.outputs.action != 'closed' && steps.meta.outputs.same-repo != 'true' | |
| run: | | |
| echo "::notice::Skipping preview deploy for fork PR #${{ steps.meta.outputs.pr-number }}" | |
| exit 0 | |
| - name: Download docs artifact | |
| if: steps.meta.outputs.action != 'closed' && steps.meta.outputs.same-repo == 'true' | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| with: | |
| name: docs-preview | |
| path: docs-preview-html/ | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Deploy preview | |
| if: steps.meta.outputs.action != 'closed' && steps.meta.outputs.same-repo == 'true' | |
| uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1 | |
| with: | |
| source-dir: ./docs-preview-html/ | |
| preview-branch: gh-pages | |
| umbrella-dir: pr-preview | |
| action: deploy | |
| pr-number: ${{ steps.meta.outputs.pr-number }} | |
| comment: false | |
| - name: Post preview comment | |
| if: steps.meta.outputs.action != 'closed' && steps.meta.outputs.same-repo == 'true' | |
| uses: marocchino/sticky-pull-request-comment@70d2764d1a7d5d9560b100cbea0077fc8f633987 # v3.0.2 | |
| with: | |
| header: pr-preview | |
| number: ${{ steps.meta.outputs.pr-number }} | |
| message: | | |
| :rocket: **Docs preview ready!** | |
| https://NVIDIA.github.io/NemoClaw/pr-preview/pr-${{ steps.meta.outputs.pr-number }}/ | |
| - name: Remove preview | |
| if: steps.meta.outputs.action == 'closed' | |
| uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1 | |
| with: | |
| preview-branch: gh-pages | |
| umbrella-dir: pr-preview | |
| action: remove | |
| pr-number: ${{ steps.meta.outputs.pr-number }} | |
| comment: false | |
| - name: Remove preview comment | |
| if: steps.meta.outputs.action == 'closed' | |
| uses: marocchino/sticky-pull-request-comment@70d2764d1a7d5d9560b100cbea0077fc8f633987 # v3.0.2 | |
| with: | |
| header: pr-preview | |
| number: ${{ steps.meta.outputs.pr-number }} | |
| delete: true |