Skip to content

Commit 928df33

Browse files
committed
CI: Add comprehensive documentation workflow
- Create docs.yaml workflow for documentation CI/CD with: * Documentation build testing and broken link detection * Rust API documentation generation and integration * GitHub Pages deployment on develop branch * Versioned documentation creation on tag releases - Update Docusaurus config to include API documentation links - Add Makefile targets for Rust documentation integration
1 parent a0c7b2b commit 928df33

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

.github/workflows/docs.yaml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
tags:
8+
- 'v*'
9+
paths:
10+
- 'website/**'
11+
- 'docs/**'
12+
- '.github/workflows/docs.yaml'
13+
pull_request:
14+
paths:
15+
- 'website/**'
16+
- 'docs/**'
17+
- '.github/workflows/docs.yaml'
18+
workflow_dispatch:
19+
20+
env:
21+
NODE_VERSION: '20'
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
# Test documentation build
29+
test-docs:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ env.NODE_VERSION }}
39+
cache: 'npm'
40+
cache-dependency-path: website/package-lock.json
41+
42+
- name: Setup build dependencies
43+
run: |
44+
sudo apt update
45+
sudo apt install -y protobuf-compiler
46+
47+
- name: Install dependencies
48+
run: make docs-install
49+
50+
- name: Check for broken links
51+
run: |
52+
cd website
53+
npx docusaurus build --out-dir=build-test 2>&1 | tee build.log
54+
if grep -i "broken\|error\|failed" build.log; then
55+
echo "::warning::Found potential issues in documentation build"
56+
cat build.log
57+
fi
58+
59+
- name: Setup Rust
60+
uses: dtolnay/rust-toolchain@stable
61+
with:
62+
components: rustfmt
63+
toolchain: nightly
64+
65+
- name: Test documentation build
66+
run: make docs-build
67+
68+
- name: Upload build artifacts for testing
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: docs-build-test
72+
path: website/build
73+
retention-days: 1
74+
75+
76+
# Deploy to GitHub Pages (only on develop branch)
77+
deploy:
78+
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
79+
needs: [test-docs]
80+
runs-on: ubuntu-latest
81+
environment:
82+
name: github-pages
83+
url: ${{ steps.deployment.outputs.page_url }}
84+
85+
permissions:
86+
contents: read
87+
pages: write
88+
id-token: write
89+
90+
steps:
91+
- name: Checkout repository
92+
uses: actions/checkout@v4
93+
with:
94+
fetch-depth: 0 # Full history for versioning
95+
96+
- name: Setup Node.js
97+
uses: actions/setup-node@v4
98+
with:
99+
node-version: ${{ env.NODE_VERSION }}
100+
cache: 'npm'
101+
cache-dependency-path: website/package-lock.json
102+
103+
- name: Setup Pages
104+
uses: actions/configure-pages@v4
105+
106+
- name: Setup build dependencies
107+
run: |
108+
sudo apt update
109+
sudo apt install -y protobuf-compiler
110+
111+
- name: Install documentation dependencies
112+
run: make docs-install
113+
114+
- name: Build documentation
115+
run: |
116+
cd website
117+
# Set base URL for GitHub Pages
118+
echo "Building documentation for GitHub Pages..."
119+
npm run build
120+
env:
121+
NODE_ENV: production
122+
123+
- name: Upload to GitHub Pages
124+
uses: actions/upload-pages-artifact@v3
125+
with:
126+
path: website/build
127+
128+
- name: Deploy to GitHub Pages
129+
id: deployment
130+
uses: actions/deploy-pages@v4
131+
132+
# Create versioned documentation on tag creation
133+
version-docs:
134+
if: startsWith(github.ref, 'refs/tags/v')
135+
needs: [test-docs]
136+
runs-on: ubuntu-latest
137+
steps:
138+
- name: Checkout repository
139+
uses: actions/checkout@v4
140+
with:
141+
fetch-depth: 0
142+
143+
- name: Setup Node.js
144+
uses: actions/setup-node@v4
145+
with:
146+
node-version: ${{ env.NODE_VERSION }}
147+
cache: 'npm'
148+
cache-dependency-path: website/package-lock.json
149+
150+
- name: Install dependencies
151+
run: make docs-install
152+
153+
- name: Extract version from tag
154+
id: version
155+
run: |
156+
VERSION=${GITHUB_REF#refs/tags/v}
157+
echo "version=$VERSION" >> $GITHUB_OUTPUT
158+
echo "Creating version $VERSION"
159+
160+
- name: Create versioned documentation
161+
run: |
162+
cd website
163+
# Create a new version of the documentation
164+
npm run docusaurus docs:version ${{ steps.version.outputs.version }}
165+
166+
- name: Setup build dependencies
167+
run: |
168+
sudo apt update
169+
sudo apt install -y protobuf-compiler
170+
171+
- name: Build versioned documentation
172+
run: |
173+
cd website
174+
npm run build
175+
env:
176+
NODE_ENV: production
177+
178+
- name: Create versioned documentation archive
179+
run: |
180+
cd website/build
181+
tar -czf "../../openmina-docs-${{ steps.version.outputs.version }}.tar.gz" .
182+
cd ../..
183+
zip -r "openmina-docs-${{ steps.version.outputs.version }}.zip" website/build
184+
185+
- name: Upload versioned documentation as release asset
186+
uses: actions/upload-artifact@v4
187+
with:
188+
name: versioned-docs-${{ steps.version.outputs.version }}
189+
path: |
190+
openmina-docs-${{ steps.version.outputs.version }}.tar.gz
191+
openmina-docs-${{ steps.version.outputs.version }}.zip

0 commit comments

Comments
 (0)