Skip to content

Commit e19730f

Browse files
committed
⚙️ Resolve git conflict.
2 parents 77e8ec6 + ba03cc6 commit e19730f

File tree

3 files changed

+378
-2
lines changed

3 files changed

+378
-2
lines changed

.github/workflows/docs-build-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
run_install: false
5656

5757
- name: Setup Node.js
58-
uses: actions/setup-node@v5
58+
uses: actions/setup-node@v6
5959
with:
6060
node-version: '22'
6161
cache: 'pnpm'

.github/workflows/documentation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110

111111
# Then setup Node.js with pnpm cache
112112
- name: Setup Node.js
113-
uses: actions/setup-node@v5
113+
uses: actions/setup-node@v6
114114
with:
115115
node-version: '22'
116116
cache: 'pnpm'
Lines changed: 376 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,376 @@
1+
name: 'Documentation Operations'
2+
description: 'Build, test, version, and deploy documentation with Docusaurus'
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
operation:
8+
description: 'Operation to perform: build, test, version, deploy-preview, deploy-production'
9+
required: true
10+
type: string
11+
node-version:
12+
description: 'Node.js version to use'
13+
required: false
14+
default: '22'
15+
type: string
16+
version:
17+
description: 'Documentation version for versioning operation'
18+
required: false
19+
default: ''
20+
type: string
21+
sections:
22+
description: 'JSON array of docs sections to version (e.g. ["docs", "dev"])'
23+
required: false
24+
default: '["docs"]'
25+
type: string
26+
strategy:
27+
description: 'Versioning strategy: changed (only changed sections) or always (all sections)'
28+
required: false
29+
default: 'always'
30+
type: string
31+
changed-sections:
32+
description: 'JSON array of sections that have changes (used with strategy: changed)'
33+
required: false
34+
default: '[]'
35+
type: string
36+
preview-branch:
37+
description: 'Branch name for preview deployment'
38+
required: false
39+
default: 'docs-preview'
40+
type: string
41+
working-directory:
42+
description: 'Working directory for documentation'
43+
required: false
44+
default: 'docs'
45+
type: string
46+
checkout-sha:
47+
description: 'Specific commit SHA to checkout (for post-version-bump code)'
48+
required: false
49+
default: ''
50+
type: string
51+
commit-changes:
52+
description: 'Whether to commit version changes'
53+
required: false
54+
default: false
55+
type: boolean
56+
upload-artifacts:
57+
description: 'Whether to upload build artifacts'
58+
required: false
59+
default: true
60+
type: boolean
61+
62+
outputs:
63+
build-success:
64+
description: 'Whether build was successful'
65+
value: ${{ jobs.docs_operations.outputs.build_success || jobs.version_docs_sequential.result == 'success' }}
66+
deploy-url:
67+
description: 'Deployment URL (for preview deployments)'
68+
value: ${{ jobs.docs_operations.outputs.deploy_url }}
69+
versioned-sections:
70+
description: 'JSON array of sections that were versioned'
71+
value: ${{ jobs.prepare_matrix.outputs.sections_to_version }}
72+
73+
jobs:
74+
prepare_matrix:
75+
name: Prepare versioning matrix
76+
if: inputs.operation == 'version'
77+
runs-on: ubuntu-latest
78+
outputs:
79+
sections_to_version: ${{ steps.matrix.outputs.sections_to_version }}
80+
has_sections: ${{ steps.matrix.outputs.has_sections }}
81+
steps:
82+
- name: Prepare sections matrix
83+
id: matrix
84+
run: |
85+
echo "🔍 Preparing versioning matrix..."
86+
87+
# Parse input sections
88+
SECTIONS='${{ inputs.sections }}'
89+
STRATEGY='${{ inputs.strategy }}'
90+
CHANGED_SECTIONS='${{ inputs.changed-sections }}'
91+
92+
echo "Input sections: $SECTIONS"
93+
echo "Strategy: $STRATEGY"
94+
echo "Changed sections: $CHANGED_SECTIONS"
95+
96+
# Determine sections to version based on strategy
97+
if [ "$STRATEGY" = "changed" ] && [ "$CHANGED_SECTIONS" != "[]" ]; then
98+
# Only version sections that have changes
99+
SECTIONS_TO_VERSION="$CHANGED_SECTIONS"
100+
echo "Using changed sections only: $SECTIONS_TO_VERSION"
101+
else
102+
# Version all requested sections (strategy: always or no changes detected)
103+
SECTIONS_TO_VERSION="$SECTIONS"
104+
echo "Using all sections: $SECTIONS_TO_VERSION"
105+
fi
106+
107+
# Check if we have any sections to version
108+
if [ "$SECTIONS_TO_VERSION" = "[]" ] || [ "$SECTIONS_TO_VERSION" = "" ]; then
109+
echo "No sections to version"
110+
echo "has_sections=false" >> $GITHUB_OUTPUT
111+
echo "sections_to_version=[]" >> $GITHUB_OUTPUT
112+
else
113+
echo "Sections to version: $SECTIONS_TO_VERSION"
114+
echo "has_sections=true" >> $GITHUB_OUTPUT
115+
echo "sections_to_version=$SECTIONS_TO_VERSION" >> $GITHUB_OUTPUT
116+
fi
117+
118+
version_docs_sequential:
119+
name: Version documentation sections
120+
if: inputs.operation == 'version' && needs.prepare_matrix.outputs.has_sections == 'true'
121+
needs: prepare_matrix
122+
runs-on: ubuntu-latest
123+
steps:
124+
- name: Checkout repository
125+
uses: actions/checkout@v5
126+
with:
127+
fetch-depth: 0
128+
# Use specific SHA if provided (for post-version-bump code), otherwise use conditional ref logic
129+
ref: ${{ inputs.checkout-sha != '' && inputs.checkout-sha || (github.event_name == 'push' && github.ref_name == 'master' && github.ref_name || '') }}
130+
131+
- name: Set up Node.js
132+
uses: actions/setup-node@v6
133+
with:
134+
node-version: ${{ inputs.node-version }}
135+
136+
- name: Enable Corepack
137+
run: corepack enable
138+
139+
- name: Cache dependencies
140+
uses: actions/cache@v4
141+
with:
142+
path: |
143+
${{ inputs.working-directory }}/node_modules
144+
~/.pnpm
145+
key: docs-${{ runner.os }}-${{ inputs.node-version }}-${{ hashFiles(format('{0}/pnpm-lock.yaml', inputs.working-directory)) }}
146+
restore-keys: |
147+
docs-${{ runner.os }}-${{ inputs.node-version }}-
148+
docs-${{ runner.os }}-
149+
150+
- name: Install dependencies
151+
working-directory: ${{ inputs.working-directory }}
152+
run: |
153+
echo "📦 Installing documentation dependencies..."
154+
pnpm install --frozen-lockfile
155+
echo "✅ Dependencies installed successfully"
156+
157+
- name: Version documentation sections sequentially
158+
working-directory: ${{ inputs.working-directory }}
159+
run: |
160+
echo "🏷️ Versioning documentation sections sequentially to prevent git conflicts..."
161+
162+
# Parse sections array and version each one sequentially
163+
SECTIONS='${{ needs.prepare_matrix.outputs.sections_to_version }}'
164+
echo "Sections to version: $SECTIONS"
165+
166+
# Convert JSON array to bash array and process sequentially
167+
echo "$SECTIONS" | jq -r '.[]' | while read -r section; do
168+
echo "🔄 Versioning section: $section"
169+
170+
# Version this specific section
171+
pnpm exec docusaurus docs:version:$section "${{ inputs.version }}"
172+
173+
echo "✅ Section '$section' versioned successfully"
174+
done
175+
176+
echo "🎉 All sections versioned successfully"
177+
178+
- name: Configure git for commits
179+
if: inputs.commit-changes
180+
run: |
181+
git config --global user.email "[email protected]"
182+
git config --global user.name "GitHub Action"
183+
184+
- name: Commit all version changes
185+
if: inputs.commit-changes
186+
run: |
187+
echo "💾 Committing all documentation version changes..."
188+
git add ${{ inputs.working-directory }}/
189+
if git diff --staged --quiet; then
190+
echo "ℹ️ No documentation changes to commit"
191+
else
192+
# Create a single commit for all sections to avoid race conditions
193+
git commit -m "📚 docs: version ${{ inputs.version }} for sections ${{ needs.prepare_matrix.outputs.sections_to_version }}"
194+
# Only push to ref_name for push events to master, use HEAD for PR events
195+
git push origin HEAD:${{ github.event_name == 'push' && github.ref_name == 'master' && github.ref_name || github.head_ref || github.ref_name }}
196+
echo "✅ All version changes committed successfully"
197+
fi
198+
199+
docs_operations:
200+
name: Docs ${{ inputs.operation }}
201+
if: inputs.operation != 'version'
202+
runs-on: ubuntu-latest
203+
outputs:
204+
build_success: ${{ steps.build.outputs.success }}
205+
deploy_url: ${{ steps.preview.outputs.url }}
206+
steps:
207+
- name: Checkout repository
208+
uses: actions/checkout@v5
209+
with:
210+
fetch-depth: 0
211+
# Use specific SHA if provided (for post-version-bump code), otherwise use conditional ref logic
212+
ref: ${{ inputs.checkout-sha != '' && inputs.checkout-sha || (github.event_name == 'push' && github.ref_name == 'master' && github.ref_name || '') }}
213+
214+
- name: Set up Node.js
215+
uses: actions/setup-node@v6
216+
with:
217+
node-version: ${{ inputs.node-version }}
218+
219+
- name: Enable Corepack
220+
run: corepack enable
221+
222+
- name: Cache dependencies
223+
uses: actions/cache@v4
224+
with:
225+
path: |
226+
${{ inputs.working-directory }}/node_modules
227+
~/.pnpm
228+
key: docs-${{ runner.os }}-${{ inputs.node-version }}-${{ hashFiles(format('{0}/pnpm-lock.yaml', inputs.working-directory)) }}
229+
restore-keys: |
230+
docs-${{ runner.os }}-${{ inputs.node-version }}-
231+
docs-${{ runner.os }}-
232+
233+
- name: Install dependencies
234+
working-directory: ${{ inputs.working-directory }}
235+
run: |
236+
echo "📦 Installing documentation dependencies..."
237+
pnpm install --frozen-lockfile
238+
echo "✅ Dependencies installed successfully"
239+
240+
# Note: Versioning is now handled by the version_docs_sequential job
241+
242+
- name: Sync changelog
243+
if: contains(fromJSON('["version", "build", "deploy-production"]'), inputs.operation)
244+
run: |
245+
echo "📄 Syncing changelog..."
246+
if [ -f CHANGELOG.md ]; then
247+
mkdir -p ${{ inputs.working-directory }}/release-notes
248+
cp CHANGELOG.md ${{ inputs.working-directory }}/release-notes/changelog.md
249+
echo "✅ Changelog synced"
250+
else
251+
echo "ℹ️ No CHANGELOG.md found, skipping sync"
252+
fi
253+
254+
- name: Build documentation
255+
if: contains(fromJSON('["build", "test", "deploy-preview", "deploy-production"]'), inputs.operation)
256+
id: build
257+
working-directory: ${{ inputs.working-directory }}
258+
run: |
259+
echo "🔨 Building documentation..."
260+
pnpm build
261+
262+
echo "✅ Documentation build completed successfully"
263+
echo "success=true" >> $GITHUB_OUTPUT
264+
265+
# Check build output
266+
echo "📁 Build output:"
267+
ls -la build/
268+
269+
- name: Test documentation
270+
if: inputs.operation == 'test'
271+
working-directory: ${{ inputs.working-directory }}
272+
run: |
273+
echo "🧪 Testing documentation..."
274+
275+
# Test that essential files exist
276+
if [ ! -f build/index.html ]; then
277+
echo "❌ Missing main index.html"
278+
exit 1
279+
fi
280+
281+
# Test that documentation structure is valid
282+
if [ ! -d build/docs ]; then
283+
echo "❌ Missing docs directory"
284+
exit 1
285+
fi
286+
287+
# Check for broken links (if available)
288+
if command -v linkchecker > /dev/null 2>&1; then
289+
echo "🔗 Checking for broken links..."
290+
linkchecker build/index.html || echo "⚠️ Link checker found issues"
291+
fi
292+
293+
echo "✅ Documentation tests passed"
294+
295+
- name: Upload build artifacts
296+
if: inputs.upload-artifacts && contains(fromJSON('["build", "test", "deploy-preview", "deploy-production"]'), inputs.operation)
297+
uses: actions/upload-artifact@v4
298+
with:
299+
name: documentation-build
300+
path: ${{ inputs.working-directory }}/build/
301+
retention-days: 30
302+
303+
- name: Configure git for commits
304+
if: inputs.commit-changes && contains(fromJSON('["version", "deploy-production"]'), inputs.operation)
305+
run: |
306+
git config --global user.email "[email protected]"
307+
git config --global user.name "GitHub Action"
308+
309+
- name: Commit version changes
310+
if: inputs.commit-changes && inputs.operation == 'version'
311+
run: |
312+
echo "💾 Committing version changes..."
313+
git add ${{ inputs.working-directory }}/
314+
if git diff --staged --quiet; then
315+
echo "ℹ️ No documentation changes to commit"
316+
else
317+
git commit -m "📚 docs: version ${{ inputs.version }}"
318+
echo "✅ Version changes committed"
319+
fi
320+
321+
- name: Deploy to preview branch
322+
if: inputs.operation == 'deploy-preview'
323+
id: preview
324+
run: |
325+
echo "🚀 Deploying to preview branch: ${{ inputs.preview-branch }}..."
326+
327+
# Create or switch to preview branch
328+
git checkout -B ${{ inputs.preview-branch }}
329+
330+
# Copy build files to root for GitHub Pages
331+
cp -r ${{ inputs.working-directory }}/build/* .
332+
333+
# Add and commit
334+
git add .
335+
git commit -m "📚 docs: preview deployment $(date -u +%Y-%m-%dT%H:%M:%SZ)" || echo "No changes to commit"
336+
337+
# Push to preview branch
338+
git push origin ${{ inputs.preview-branch }} --force
339+
340+
# Set preview URL
341+
PREVIEW_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}"
342+
echo "url=$PREVIEW_URL" >> $GITHUB_OUTPUT
343+
echo "✅ Preview deployed to: $PREVIEW_URL"
344+
345+
- name: Deploy to production
346+
if: inputs.operation == 'deploy-production'
347+
run: |
348+
echo "🚀 Deploying to production..."
349+
350+
# Commit and push documentation changes if any
351+
git add ${{ inputs.working-directory }}/
352+
if ! git diff --staged --quiet; then
353+
git commit -m "📚 docs: production deployment ${{ inputs.version }}"
354+
# Only push to ref_name for push events to master, use HEAD for PR events
355+
git push origin HEAD:${{ github.event_name == 'push' && github.ref_name == 'master' && github.ref_name || github.head_ref || github.ref_name }}
356+
echo "✅ Documentation changes pushed to production"
357+
else
358+
echo "ℹ️ No documentation changes to deploy"
359+
fi
360+
361+
- name: Operation summary
362+
run: |
363+
echo "## Documentation Operation Summary" >> $GITHUB_STEP_SUMMARY
364+
echo "- **Operation**: ${{ inputs.operation }}" >> $GITHUB_STEP_SUMMARY
365+
echo "- **Node.js**: ${{ inputs.node-version }}" >> $GITHUB_STEP_SUMMARY
366+
echo "- **Working Directory**: ${{ inputs.working-directory }}" >> $GITHUB_STEP_SUMMARY
367+
368+
if [ "${{ inputs.operation }}" = "version" ] && [ "${{ inputs.version }}" != "" ]; then
369+
echo "- **Version**: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
370+
fi
371+
372+
if [ "${{ inputs.operation }}" = "deploy-preview" ] && [ "${{ steps.preview.outputs.url }}" != "" ]; then
373+
echo "- **Preview URL**: ${{ steps.preview.outputs.url }}" >> $GITHUB_STEP_SUMMARY
374+
fi
375+
376+
echo "- **Status**: ✅ Completed successfully" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)