Repository navigation
194 lines (172 loc) · 6.48 KB
/
Copy pathdocs-build.yaml
File metadata and controls
194 lines (172 loc) · 6.48 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
name: docs-build
on:
pull_request:
branches: [develop]
types: [opened, synchronize]
paths:
- ".github/workflows/docs-build.yaml"
- "Makefile"
- "docs/**"
- "fern/**"
- "package.json"
- "package-lock.json"
- "scripts/normalize-fern-sdk-reference.mjs"
- "scripts/cache-fern-ref-sdk.mjs"
- "scripts/fern-ref-sdk-environment.mjs"
- "scripts/fern-ref-sdk-hooks/**"
- "scripts/run-fern-with-ref-sdk.mjs"
- "scripts/tests/**"
- "scripts/watch-fern-preview.mjs"
- "scripts/fix-empty-fern-links.mjs"
push:
branches: [develop]
tags:
- docs-v*
- v*
paths:
- ".github/workflows/docs-build.yaml"
- "Makefile"
- "docs/**"
- "fern/**"
- "package.json"
- "package-lock.json"
- "scripts/normalize-fern-sdk-reference.mjs"
- "scripts/cache-fern-ref-sdk.mjs"
- "scripts/fern-ref-sdk-environment.mjs"
- "scripts/fern-ref-sdk-hooks/**"
- "scripts/run-fern-with-ref-sdk.mjs"
- "scripts/tests/**"
- "scripts/watch-fern-preview.mjs"
- "scripts/fix-empty-fern-links.mjs"
workflow_dispatch:
defaults:
run:
shell: bash
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-docs:
name: Check Fern docs
if: github.event_name != 'pull_request' || github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
package-manager-cache: false
- name: Install documentation dependencies
run: npm ci
- name: Test Fern documentation scripts
run: make test-docs-scripts
- name: Check Fern docs
env:
FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
run: make docs-fern-strict
preview-docs:
name: Publish Fern preview
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
needs: [build-docs]
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
package-manager-cache: false
- name: Install documentation dependencies
run: npm ci
- name: Restore historical SDK references
uses: actions/cache/restore@v6
with:
path: .fern-cache/fern-ref-sdk
key: fern-ref-sdk-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'fern/fern.config.json', 'fern/docs.yml', 'scripts/cache-fern-ref-sdk.mjs', 'scripts/fern-ref-sdk-environment.mjs', 'scripts/fern-ref-sdk-hooks/**', 'scripts/normalize-fern-sdk-reference.mjs') }}
restore-keys: |
fern-ref-sdk-${{ runner.os }}-
- name: Generate Python SDK reference
env:
FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
run: make docs-fern-generate-sdk
- name: Publish Fern preview
env:
FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
PREVIEW_ID: pr-${{ github.event.pull_request.number }}
FERN_DOCS_INSTANCE: nvidia-nemo-guardrails.docs.buildwithfern.com/nemo/guardrails
run: node scripts/run-fern-with-ref-sdk.mjs generate --docs --preview --id "${PREVIEW_ID}" --force --instance "${FERN_DOCS_INSTANCE}"
- name: Comment preview URL
uses: actions/github-script@v9
with:
script: |
const previewUrl = `https://nvidia-preview-pr-${context.issue.number}.docs.buildwithfern.com/nemo/guardrails`;
const marker = '<!-- guardrails-fern-preview -->';
const body = `${marker}\nStaged Fern docs preview: ${previewUrl}`;
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find((comment) => comment.body?.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
publish-staging:
name: Publish Fern staging docs
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
needs: [build-docs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
package-manager-cache: false
- name: Install documentation dependencies
run: npm ci
- name: Restore historical SDK references
id: fern-sdk-cache
uses: actions/cache/restore@v6
with:
path: .fern-cache/fern-ref-sdk
key: fern-ref-sdk-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'fern/fern.config.json', 'fern/docs.yml', 'scripts/cache-fern-ref-sdk.mjs', 'scripts/fern-ref-sdk-environment.mjs', 'scripts/fern-ref-sdk-hooks/**', 'scripts/normalize-fern-sdk-reference.mjs') }}
restore-keys: |
fern-ref-sdk-${{ runner.os }}-
- name: Publish Fern staging docs
env:
FERN_TOKEN: ${{ secrets.DOCS_FERN_TOKEN }}
run: make docs-fern-publish-staging
- name: Save historical SDK references
if: steps.fern-sdk-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: .fern-cache/fern-ref-sdk
key: fern-ref-sdk-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'fern/fern.config.json', 'fern/docs.yml', 'scripts/cache-fern-ref-sdk.mjs', 'scripts/fern-ref-sdk-environment.mjs', 'scripts/fern-ref-sdk-hooks/**', 'scripts/normalize-fern-sdk-reference.mjs') }}