-
-
Notifications
You must be signed in to change notification settings - Fork 180
242 lines (205 loc) · 7.22 KB
/
Copy pathdocs.yml
File metadata and controls
242 lines (205 loc) · 7.22 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
name: Documentation
on:
push:
branches: [ main ]
paths:
- 'docs/**'
- 'res/**'
- 'package.json'
- 'packages/**/*.ts'
- 'packages/**/*.tsx'
- 'typedoc.json'
- 'scripts/generate-api-docs.cjs'
- 'scripts/sync-brand-assets.mjs'
- '.github/workflows/docs.yml'
pull_request:
branches: [ main, next ]
paths:
- 'docs/**'
- 'res/**'
- 'package.json'
- 'packages/**/*.ts'
- 'packages/**/*.tsx'
- 'typedoc.json'
- 'scripts/generate-api-docs.cjs'
- 'scripts/sync-brand-assets.mjs'
# Allow manual triggering
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
pull-requests: write
issues: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10
- name: Install root dependencies
run: npm install
- name: Resolve n8n stable tag
id: n8n-tag
run: echo "tag=$(node scripts/ensure-n8n-cache.cjs --print-tag)" >> "$GITHUB_OUTPUT"
- name: Cache n8n repository
uses: actions/cache@v4
with:
path: .n8n-cache
key: ${{ runner.os }}-n8n-cache-${{ steps.n8n-tag.outputs.tag }}-${{ hashFiles('scripts/ensure-n8n-cache.cjs') }}
restore-keys: |
${{ runner.os }}-n8n-cache-
- name: Build packages
run: npm run build
- name: Install docs dependencies
working-directory: ./docs
run: npm install
- name: Generate API documentation
run: npm run docs:api
- name: Build documentation
working-directory: ./docs
run: npm run build
- name: Setup Pages
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
uses: actions/configure-pages@v4
- name: Upload artifact
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/build
- name: Run documentation tests
run: |
# Check if documentation builds successfully
if [ ! -d "./docs/build" ]; then
echo "Documentation build failed - build directory not found"
exit 1
fi
# Check for broken links (basic check)
echo "Checking for broken internal links..."
# We exclude 404.html because it naturally contains "Page Not Found"
find ./docs/build -name "*.html" -type f ! -name "404.html" | head -20 | while read file; do
echo "Checking $file"
if grep -q "Page Not Found" "$file"; then
echo "ERROR: Found 'Page Not Found' in $file"
exit 1
fi
done
echo "Documentation build validation passed"
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Documentation validation job (runs on PRs)
validate:
env:
GITHUB_TOKEN: ${{ github.token }}
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10
- name: Install root dependencies
run: npm install
- name: Install docs dependencies
working-directory: ./docs
run: npm install
- name: Validate documentation structure
run: |
echo "Validating documentation structure..."
# Check required directories exist
required_dirs=(
"docs/docs/home"
"docs/docs/getting-started"
"docs/docs/usage"
"docs/docs/contribution"
"docs/docs/community"
)
for dir in "${required_dirs[@]}"; do
if [ ! -d "$dir" ]; then
echo "ERROR: Required directory $dir not found"
exit 1
fi
done
# Check required configuration files
required_files=(
"docs/docusaurus.config.ts"
"docs/sidebars.ts"
"docs/sidebars.api.ts"
"docs/src/css/custom.css"
)
for file in "${required_files[@]}"; do
if [ ! -f "$file" ]; then
echo "ERROR: Required file $file not found"
exit 1
fi
done
echo "Documentation structure validation passed"
- name: TypeScript type checking
working-directory: ./docs
run: npm run typecheck
- name: Check for broken links in markdown
run: |
echo "Checking for broken markdown links..."
# Install markdown link checker if not present
if ! command -v markdown-link-check &> /dev/null; then
npm install -g markdown-link-check
fi
# Check a subset of markdown files
find docs/docs -name "*.md" -type f | head -10 | while read file; do
echo "Checking $file"
markdown-link-check "$file" --config .github/markdown-link-check-config.json 2>/dev/null || true
done
- name: Generate API documentation (dry run)
run: npm run docs:api -- --dry-run 2>/dev/null || echo "API generation check completed"
- name: Comment on PR with documentation preview
if: always()
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request.number;
const success = '${{ job.status }}' === 'success';
const message = success
? `✅ Documentation validation passed! The documentation changes look good.\n\nOnce merged, the documentation will be automatically deployed to GitHub Pages.`
: `❌ Documentation validation failed. Please check the workflow logs for details.`;
await github.rest.issues.createComment({
owner,
repo,
issue_number: prNumber,
body: `## Documentation Validation\n\n${message}\n\n**Workflow:** ${{ github.workflow }} #${{ github.run_id }}`
});