Docusaurus website #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Documentation | |
on: | |
push: | |
branches: | |
- develop | |
tags: | |
- 'v*' | |
paths: | |
- 'website/**' | |
- 'docs/**' | |
- '.github/workflows/docs.yaml' | |
pull_request: | |
paths: | |
- 'website/**' | |
- 'docs/**' | |
- '.github/workflows/docs.yaml' | |
workflow_dispatch: | |
env: | |
NODE_VERSION: '20' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# Test documentation build | |
test-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'npm' | |
cache-dependency-path: website/package-lock.json | |
- name: Install dependencies | |
run: make docs-install | |
- name: Check for broken links | |
run: | | |
cd website | |
npx docusaurus build --out-dir=build-test 2>&1 | tee build.log | |
if grep -i "broken\|error\|failed" build.log; then | |
echo "::warning::Found potential issues in documentation build" | |
cat build.log | |
fi | |
- name: Test documentation build | |
run: make docs-build | |
- name: Upload build artifacts for testing | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs-build-test | |
path: website/build | |
retention-days: 1 | |
# Deploy to GitHub Pages (only on develop branch) | |
deploy: | |
if: github.ref == 'refs/heads/develop' && github.event_name == 'push' | |
needs: [test-docs] | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Full history for versioning | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'npm' | |
cache-dependency-path: website/package-lock.json | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Install documentation dependencies | |
run: make docs-install | |
- name: Build documentation | |
run: | | |
cd website | |
# Set base URL for GitHub Pages | |
echo "Building documentation for GitHub Pages..." | |
npm run build | |
env: | |
NODE_ENV: production | |
- name: Upload to GitHub Pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: website/build | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
# Create versioned documentation on tag creation | |
version-docs: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [test-docs] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'npm' | |
cache-dependency-path: website/package-lock.json | |
- name: Install dependencies | |
run: make docs-install | |
- name: Extract version from tag | |
id: version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/v} | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "Creating version $VERSION" | |
- name: Create versioned documentation | |
run: | | |
cd website | |
# Create a new version of the documentation | |
npm run docusaurus docs:version ${{ steps.version.outputs.version }} | |
- name: Build versioned documentation | |
run: | | |
cd website | |
npm run build | |
env: | |
NODE_ENV: production | |
- name: Create versioned documentation archive | |
run: | | |
cd website/build | |
tar -czf "../../openmina-docs-${{ steps.version.outputs.version }}.tar.gz" . | |
cd ../.. | |
zip -r "openmina-docs-${{ steps.version.outputs.version }}.zip" website/build | |
- name: Upload versioned documentation as release asset | |
uses: actions/upload-artifact@v4 | |
with: | |
name: versioned-docs-${{ steps.version.outputs.version }} | |
path: | | |
openmina-docs-${{ steps.version.outputs.version }}.tar.gz | |
openmina-docs-${{ steps.version.outputs.version }}.zip | |
# Rust documentation integration job | |
rust-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: 1.84 | |
- name: Setup build dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y protobuf-compiler | |
- name: Generate Rust documentation | |
run: make docs-rust | |
- name: Upload Rust documentation | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rust-docs | |
path: target/doc | |
retention-days: 7 | |
- name: Create documentation integration plan | |
run: | | |
echo "# Rust Documentation Integration Plan" > rust-docs-plan.md | |
echo "" >> rust-docs-plan.md | |
echo "## Generated Documentation" >> rust-docs-plan.md | |
echo "- Location: target/doc/" >> rust-docs-plan.md | |
echo "- Entry point: target/doc/index.html" >> rust-docs-plan.md | |
echo "- Packages documented:" >> rust-docs-plan.md | |
find target/doc -name "index.html" -not -path "*/src/*" | sed 's|target/doc/||g' | sed 's|/index.html||g' | sort | sed 's/^/ - /' >> rust-docs-plan.md | |
echo "" >> rust-docs-plan.md | |
echo "## Integration Steps" >> rust-docs-plan.md | |
echo "1. Copy target/doc/ to website/static/api-docs/" >> rust-docs-plan.md | |
echo "2. Add link in docusaurus.config.ts navigation" >> rust-docs-plan.md | |
echo "3. Create API documentation landing page" >> rust-docs-plan.md | |
cat rust-docs-plan.md | |
- name: Upload integration plan | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rust-docs-integration-plan | |
path: rust-docs-plan.md |