-
Notifications
You must be signed in to change notification settings - Fork 53
336 lines (310 loc) · 12.7 KB
/
Copy pathdocs.yaml
File metadata and controls
336 lines (310 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Build docs and Teleop web app, then deploy to GitHub Pages.
# - Push to main/release/v* tag (canonical repo): deploy docs at site root, web app at /client/<slug>/.
# Tag pushes also promote /client/stable/ to the highest v* tag.
# - Same-repo PR: auto-deploy preview to preview/pr-<N>/.
# - Fork PR: build only; a maintainer can deploy via `/preview-docs` (see
# docs-preview-on-demand.yaml).
#
# Builds are gated on changed paths by the `changes` job; gh-pages
# `keep_files: true` preserves whichever artifact was skipped.
#
# Web client uses the private CloudXR SDK for pushes and for PRs whose
# author is in ALLOWED_CLOUDXR_JS_PR_AUTHORS (Repo Settings → Variables);
# all other PRs fall back to the public SDK.
name: Build & deploy docs
on:
push:
branches:
- main
- 'release/**'
tags:
- 'v[1-9]*.[0-9]*.[0-9]*'
pull_request:
types: [opened, synchronize, reopened]
paths:
- "docs/**"
- ".github/workflows/docs.yaml"
- ".github/actions/build-cloudxr-web-client/**"
- "deps/cloudxr/webxr_client/**"
- "deps/cloudxr/.env.default"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-repo:
name: Check repo
runs-on: ubuntu-latest
permissions: {}
outputs:
is-canonical-repo: ${{ steps.is-canonical-repo.outputs.defined }}
is-deploy-branch: ${{ steps.is-deploy-branch.outputs.defined }}
use_ngc_key: ${{ steps.ngc-allowlist.outputs.use_ngc_key }}
steps:
- id: is-canonical-repo
if: github.repository == 'NVIDIA/IsaacTeleop'
run: echo "defined=true" >> "$GITHUB_OUTPUT"
- id: is-deploy-branch
if: >-
github.ref == 'refs/heads/main'
|| startsWith(github.ref, 'refs/heads/release/')
|| startsWith(github.ref, 'refs/tags/v')
run: echo "defined=true" >> "$GITHUB_OUTPUT"
- id: ngc-allowlist
run: |
if [ "${{ github.event_name }}" != 'pull_request' ]; then
echo "use_ngc_key=true" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "use_ngc_key=false" >> "$GITHUB_OUTPUT"
else
ACTOR="${{ github.actor }}"
ALLOWED="${{ vars.ALLOWED_CLOUDXR_JS_PR_AUTHORS }}"
# Normalize: remove spaces so "alice, bob" matches like "alice,bob"
ALLOWED="${ALLOWED// /}"
case ",${ALLOWED}," in
*",${ACTOR},"*) echo "use_ngc_key=true" >> "$GITHUB_OUTPUT" ;;
*) echo "use_ngc_key=false" >> "$GITHUB_OUTPUT" ;;
esac
fi
# gh-pages keep_files preserves whichever artifact isn't rebuilt this run.
changes:
name: Detect changed paths
runs-on: ubuntu-latest
permissions: {}
outputs:
docs: ${{ steps.filter.outputs.docs }}
webapp: ${{ steps.filter.outputs.webapp }}
steps:
- name: Checkout (with history)
uses: actions/checkout@v6
with:
fetch-depth: 0
- id: filter
env:
EVENT: ${{ github.event_name }}
BEFORE: ${{ github.event.before }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if [ "$EVENT" = 'pull_request' ]; then
git fetch --no-tags --depth=1 origin "$BASE_REF"
base="$(git merge-base FETCH_HEAD HEAD || true)"
elif [ -n "$BEFORE" ] && [ "$BEFORE" != '0000000000000000000000000000000000000000' ]; then
base="$BEFORE"
else
base="" # new branch / force push: treat everything as changed
fi
files="$([ -n "$base" ] && git diff --name-only "$base" HEAD || git ls-tree -r --name-only HEAD)"
docs=false; webapp=false
while IFS= read -r f; do
case "$f" in
docs/*|.github/workflows/docs.yaml) docs=true ;;
esac
case "$f" in
deps/cloudxr/webxr_client/*|deps/cloudxr/.env.default|.github/actions/build-cloudxr-web-client/*|.github/workflows/docs.yaml)
webapp=true ;;
esac
done <<< "$files"
echo "docs=$docs" >> "$GITHUB_OUTPUT"
echo "webapp=$webapp" >> "$GITHUB_OUTPUT"
echo "::notice::changes: docs=$docs webapp=$webapp (base=${base:-<none>})"
build-docs:
name: Build Docs
runs-on: ubuntu-latest
needs: [check-repo, changes]
if: needs.changes.outputs.docs == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install docs requirements
working-directory: ./docs
run: pip install -r requirements.txt
- name: Build docs for the current branch
working-directory: ./docs
run: make current-docs
- name: Generate multi-version docs
working-directory: ./docs
if: needs.check-repo.outputs.is-canonical-repo == 'true' && needs.check-repo.outputs.is-deploy-branch == 'true'
run: |
git fetch --prune --unshallow --tags
make multi-docs
- name: Upload docs artifact
uses: actions/upload-artifact@v6
with:
name: docs-html
path: ./docs/build
build-app:
name: Build Teleop Web App
runs-on: ubuntu-latest
needs: [check-repo, changes]
if: needs.changes.outputs.webapp == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v6
# Allowlist no → public only. Allowlist yes + NGC_API_KEY → private only.
- name: Build CloudXR web client
uses: ./.github/actions/build-cloudxr-web-client
with:
ngc-api-key: ${{ needs.check-repo.outputs.use_ngc_key == 'true' && secrets.NGC_TELEOP_CORE_GITHUB_SERVICE_KEY || '' }}
- name: Upload web app artifact
uses: actions/upload-artifact@v6
with:
name: webapp
path: deps/cloudxr/webxr_client/build
deploy-docs:
name: Deploy docs
runs-on: ubuntu-latest
needs: [check-repo, changes, build-docs, build-app]
if: >-
!cancelled()
&& needs.check-repo.outputs.is-canonical-repo == 'true'
&& (needs.check-repo.outputs.is-deploy-branch == 'true' || github.event_name == 'pull_request')
&& needs.build-docs.result != 'failure'
&& needs.build-app.result != 'failure'
&& (needs.build-docs.result == 'success' || needs.build-app.result == 'success')
permissions:
contents: write # push to gh-pages
steps:
- name: Checkout (for tag lookup)
if: github.event_name == 'push' && github.ref_type == 'tag'
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Download docs artifact
if: needs.build-docs.result == 'success'
uses: actions/download-artifact@v7
with:
name: docs-html
path: ./docs/build
- name: Download web app artifact
if: needs.build-app.result == 'success'
uses: actions/download-artifact@v7
with:
name: webapp
path: ./webapp
# Web client lands at client/<slug>/: tag → v1.2.3, main → main, release branch → release-1.3.x.
# Tag pushes also (re)point client/stable/ at the highest v* tag.
# The root client/ redirect is owned by the main branch deploy and points at ./stable/.
- name: Place web app under versioned subpath
if: needs.build-app.result == 'success'
run: |
set -euo pipefail
CLIENT_BASE=./docs/build/client
if [ "${{ github.event_name }}" = 'pull_request' ]; then
mkdir -p ./docs/build/current/client
cp -r ./webapp/. ./docs/build/current/client/
exit 0
fi
if [ "$GITHUB_REF_TYPE" = 'tag' ]; then
target="$GITHUB_REF_NAME"
else
target="${GITHUB_REF_NAME//\//-}"
fi
mkdir -p "$CLIENT_BASE/$target"
cp -r ./webapp/. "$CLIENT_BASE/$target/"
echo "Deployed web client to /client/$target/"
if [ "$GITHUB_REF" = 'refs/heads/main' ]; then
cat > "$CLIENT_BASE/index.html" <<'HTML'
<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<!DOCTYPE html>
<html>
<head>
<title>Redirecting to the stable Isaac Teleop web client</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=./stable/">
<link rel="canonical" href="./stable/">
</head>
<body>
<p>Redirecting to <a href="./stable/">the stable Isaac Teleop web client</a>.</p>
<script>location.replace('./stable/' + location.search + location.hash);</script>
</body>
</html>
HTML
fi
if [ "$GITHUB_REF_TYPE" = 'tag' ]; then
stable_slug="$(git ls-remote --tags origin 'v[1-9]*.[0-9]*.[0-9]*' \
| awk -F'refs/tags/' '{print $2}' \
| sed 's/\^{}$//' | sort -uV | tail -n1)"
if [ -z "$stable_slug" ]; then
echo "::warning::No v* tags resolved; leaving client/stable/ untouched."
exit 0
fi
mkdir -p "$CLIENT_BASE/stable"
cat > "$CLIENT_BASE/stable/index.html" <<HTML
<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<!DOCTYPE html>
<html>
<head>
<title>Redirecting to the stable Isaac Teleop web client (${stable_slug})</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=../${stable_slug}/">
<link rel="canonical" href="../${stable_slug}/">
</head>
<body>
<p>Redirecting to <a href="../${stable_slug}/">the stable Isaac Teleop web client</a>.</p>
<script>location.replace('../${stable_slug}/' + location.search + location.hash);</script>
</body>
</html>
HTML
echo "Stable now points to /client/${stable_slug}/"
fi
- name: Deploy to gh-pages
if: github.event_name == 'push' && needs.check-repo.outputs.is-deploy-branch == 'true'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
keep_files: true
# Fork PRs have a read-only GITHUB_TOKEN and can't push to gh-pages, so
# the auto-deploy is gated to same-repo PRs. Fork PR previews are
# handled by docs-preview-on-demand.yaml (slash-command triggered).
- name: Deploy PR preview to gh-pages
if: >-
github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository
uses: peaceiris/actions-gh-pages@v4
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'
&& github.event.pull_request.head.repo.full_name == github.repository
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"
- name: Note manual-trigger requirement for fork PRs
if: >-
github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name != github.repository
run: |
{
echo "## Docs preview"
echo
echo "This PR is from a fork, so the preview is **not auto-deployed**."
echo "A maintainer with write access can comment \`/preview-docs\` on"
echo "the PR to deploy a preview to:"
echo
echo "**https://nvidia.github.io/IsaacTeleop/preview/pr-${{ github.event.pull_request.number }}/**"
} >> "$GITHUB_STEP_SUMMARY"