Skip to content

Commit 5017db1

Browse files
committed
➕ Add a new CI workflow about validating it could build the document finely without any problem.
1 parent 2eebe2e commit 5017db1

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Documentation (Docusaurus) Build Check
2+
3+
on:
4+
pull_request:
5+
paths:
6+
# Documentation CI workflow
7+
- ".github/workflows/docs-build-check.yaml"
8+
- ".github/workflows/documentation.yaml"
9+
# Documentation dependencies
10+
- "docs/package.json"
11+
- "docs/pnpm-lock.yaml"
12+
# Docusaurus configuration
13+
- "docs/docusaurus.config.ts"
14+
- "docs/tsconfig.json"
15+
# Documentation content
16+
- "docs/**/*.md"
17+
- "docs/**/*.mdx"
18+
- "docs/**/*.ts"
19+
- "docs/**/*.tsx"
20+
- "docs/**/*.js"
21+
- "docs/**/*.jsx"
22+
- "docs/**/*.css"
23+
- "docs/**/*.json"
24+
# Docusaurus versioning
25+
- "docs/*_versions.json"
26+
- "docs/*_versioned_docs/**"
27+
- "docs/*_versioned_sidebars/**"
28+
# Static assets
29+
- "docs/static/**"
30+
- "docs/src/**"
31+
32+
permissions:
33+
contents: read
34+
35+
# Allow cancelling in-progress runs for the same PR/branch
36+
concurrency:
37+
group: docs-build-${{ github.ref }}
38+
cancel-in-progress: true
39+
40+
jobs:
41+
build_docs:
42+
name: Build Documentation
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v5
48+
with:
49+
fetch-depth: 1 # Shallow clone for build check
50+
51+
- name: Install pnpm
52+
uses: pnpm/action-setup@v4
53+
with:
54+
version: 10
55+
run_install: false
56+
57+
- name: Setup Node.js
58+
uses: actions/setup-node@v5
59+
with:
60+
node-version: '22'
61+
cache: 'pnpm'
62+
cache-dependency-path: docs/pnpm-lock.yaml
63+
64+
- name: Install dependencies
65+
working-directory: ./docs
66+
run: pnpm install --frozen-lockfile
67+
68+
# - name: Type check
69+
# working-directory: ./docs
70+
# run: pnpm typecheck
71+
72+
- name: Build documentation
73+
working-directory: ./docs
74+
run: pnpm build
75+
76+
- name: Check build output
77+
run: |
78+
if [ ! -d "docs/build" ]; then
79+
echo "❌ Build directory not found!"
80+
exit 1
81+
fi
82+
83+
if [ ! -f "docs/build/index.html" ]; then
84+
echo "❌ Main index.html not generated!"
85+
exit 1
86+
fi
87+
88+
# Check for common build artifacts
89+
BUILD_SIZE=$(du -sh docs/build | cut -f1)
90+
echo "✅ Documentation built successfully!"
91+
echo "📁 Build size: $BUILD_SIZE"
92+
echo "📄 Files generated: $(find docs/build -type f | wc -l)"
93+
94+
- name: Validate build quality
95+
run: |
96+
# Check for broken links in build output (basic validation)
97+
cd docs/build
98+
99+
# Count HTML files
100+
HTML_COUNT=$(find . -name "*.html" | wc -l)
101+
echo "🔍 HTML files generated: $HTML_COUNT"
102+
103+
if [ "$HTML_COUNT" -lt 5 ]; then
104+
echo "⚠️ Warning: Very few HTML files generated ($HTML_COUNT)"
105+
echo "This might indicate a build issue"
106+
fi
107+
108+
# Check for critical files
109+
CRITICAL_FILES=("index.html" "404.html")
110+
for file in "${CRITICAL_FILES[@]}"; do
111+
if [ -f "$file" ]; then
112+
echo "✅ Critical file found: $file"
113+
else
114+
echo "⚠️ Critical file missing: $file"
115+
fi
116+
done
117+
118+
- name: Build summary
119+
if: always()
120+
run: |
121+
echo "## 📚 Documentation Build Summary" >> $GITHUB_STEP_SUMMARY
122+
if [ -d "docs/build" ]; then
123+
BUILD_SIZE=$(du -sh docs/build | cut -f1)
124+
FILE_COUNT=$(find docs/build -type f | wc -l)
125+
HTML_COUNT=$(find docs/build -name "*.html" | wc -l)
126+
127+
echo "✅ **Build Status**: Success" >> $GITHUB_STEP_SUMMARY
128+
echo "📁 **Build Size**: $BUILD_SIZE" >> $GITHUB_STEP_SUMMARY
129+
echo "📄 **Total Files**: $FILE_COUNT" >> $GITHUB_STEP_SUMMARY
130+
echo "🌐 **HTML Pages**: $HTML_COUNT" >> $GITHUB_STEP_SUMMARY
131+
else
132+
echo "❌ **Build Status**: Failed" >> $GITHUB_STEP_SUMMARY
133+
echo "The documentation build did not complete successfully." >> $GITHUB_STEP_SUMMARY
134+
fi

0 commit comments

Comments
 (0)