| 
 | 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: Setup Rust  | 
 | 51 | +        uses: dtolnay/rust-toolchain@stable  | 
 | 52 | +        with:  | 
 | 53 | +          components: rustfmt  | 
 | 54 | +          toolchain: nightly  | 
 | 55 | + | 
 | 56 | +      - name: Test documentation build  | 
 | 57 | +        run: make docs-build  | 
 | 58 | + | 
 | 59 | +      - name: Upload build artifacts for testing  | 
 | 60 | +        uses: actions/upload-artifact@v4  | 
 | 61 | +        with:  | 
 | 62 | +          name: docs-build-test  | 
 | 63 | +          path: website/build  | 
 | 64 | +          retention-days: 1  | 
 | 65 | + | 
 | 66 | + | 
 | 67 | +  # Deploy to GitHub Pages (only on develop branch)  | 
 | 68 | +  deploy:  | 
 | 69 | +    if: github.ref == 'refs/heads/develop' && github.event_name == 'push'  | 
 | 70 | +    needs: [test-docs]  | 
 | 71 | +    runs-on: ubuntu-latest  | 
 | 72 | +    environment:  | 
 | 73 | +      name: github-pages  | 
 | 74 | +      url: ${{ steps.deployment.outputs.page_url }}  | 
 | 75 | + | 
 | 76 | +    permissions:  | 
 | 77 | +      contents: read  | 
 | 78 | +      pages: write  | 
 | 79 | +      id-token: write  | 
 | 80 | + | 
 | 81 | +    steps:  | 
 | 82 | +      - name: Checkout repository  | 
 | 83 | +        uses: actions/checkout@v4  | 
 | 84 | +        with:  | 
 | 85 | +          fetch-depth: 0  # Full history for versioning  | 
 | 86 | + | 
 | 87 | +      - name: Setup Node.js  | 
 | 88 | +        uses: actions/setup-node@v4  | 
 | 89 | +        with:  | 
 | 90 | +          node-version: ${{ env.NODE_VERSION }}  | 
 | 91 | +          cache: 'npm'  | 
 | 92 | +          cache-dependency-path: website/package-lock.json  | 
 | 93 | + | 
 | 94 | +      - name: Setup Pages  | 
 | 95 | +        uses: actions/configure-pages@v4  | 
 | 96 | + | 
 | 97 | +      - name: Setup build dependencies  | 
 | 98 | +        run: |  | 
 | 99 | +          sudo apt update  | 
 | 100 | +          sudo apt install -y protobuf-compiler  | 
 | 101 | +
  | 
 | 102 | +      - name: Install documentation dependencies  | 
 | 103 | +        run: make docs-install  | 
 | 104 | + | 
 | 105 | +      - name: Build documentation  | 
 | 106 | +        run: |  | 
 | 107 | +          cd website  | 
 | 108 | +          # Set base URL for GitHub Pages  | 
 | 109 | +          echo "Building documentation for GitHub Pages..."  | 
 | 110 | +          npm run build  | 
 | 111 | +        env:  | 
 | 112 | +          NODE_ENV: production  | 
 | 113 | + | 
 | 114 | +      - name: Upload to GitHub Pages  | 
 | 115 | +        uses: actions/upload-pages-artifact@v3  | 
 | 116 | +        with:  | 
 | 117 | +          path: website/build  | 
 | 118 | + | 
 | 119 | +      - name: Deploy to GitHub Pages  | 
 | 120 | +        id: deployment  | 
 | 121 | +        uses: actions/deploy-pages@v4  | 
 | 122 | + | 
 | 123 | +  # Create versioned documentation on tag creation  | 
 | 124 | +  version-docs:  | 
 | 125 | +    if: startsWith(github.ref, 'refs/tags/v')  | 
 | 126 | +    needs: [test-docs]  | 
 | 127 | +    runs-on: ubuntu-latest  | 
 | 128 | +    steps:  | 
 | 129 | +      - name: Checkout repository  | 
 | 130 | +        uses: actions/checkout@v4  | 
 | 131 | +        with:  | 
 | 132 | +          fetch-depth: 0  | 
 | 133 | + | 
 | 134 | +      - name: Setup Node.js  | 
 | 135 | +        uses: actions/setup-node@v4  | 
 | 136 | +        with:  | 
 | 137 | +          node-version: ${{ env.NODE_VERSION }}  | 
 | 138 | +          cache: 'npm'  | 
 | 139 | +          cache-dependency-path: website/package-lock.json  | 
 | 140 | + | 
 | 141 | +      - name: Install dependencies  | 
 | 142 | +        run: make docs-install  | 
 | 143 | + | 
 | 144 | +      - name: Extract version from tag  | 
 | 145 | +        id: version  | 
 | 146 | +        run: |  | 
 | 147 | +          VERSION=${GITHUB_REF#refs/tags/v}  | 
 | 148 | +          echo "version=$VERSION" >> $GITHUB_OUTPUT  | 
 | 149 | +          echo "Creating version $VERSION"  | 
 | 150 | +
  | 
 | 151 | +      - name: Create versioned documentation  | 
 | 152 | +        run: |  | 
 | 153 | +          cd website  | 
 | 154 | +          # Create a new version of the documentation  | 
 | 155 | +          npm run docusaurus docs:version ${{ steps.version.outputs.version }}  | 
 | 156 | +
  | 
 | 157 | +      - name: Setup build dependencies  | 
 | 158 | +        run: |  | 
 | 159 | +          sudo apt update  | 
 | 160 | +          sudo apt install -y protobuf-compiler  | 
 | 161 | +
  | 
 | 162 | +      - name: Build versioned documentation  | 
 | 163 | +        run: |  | 
 | 164 | +          cd website  | 
 | 165 | +          npm run build  | 
 | 166 | +        env:  | 
 | 167 | +          NODE_ENV: production  | 
 | 168 | + | 
 | 169 | +      - name: Create versioned documentation archive  | 
 | 170 | +        run: |  | 
 | 171 | +          cd website/build  | 
 | 172 | +          tar -czf "../../openmina-docs-${{ steps.version.outputs.version }}.tar.gz" .  | 
 | 173 | +          cd ../..  | 
 | 174 | +          zip -r "openmina-docs-${{ steps.version.outputs.version }}.zip" website/build  | 
 | 175 | +
  | 
 | 176 | +      - name: Upload versioned documentation as release asset  | 
 | 177 | +        uses: actions/upload-artifact@v4  | 
 | 178 | +        with:  | 
 | 179 | +          name: versioned-docs-${{ steps.version.outputs.version }}  | 
 | 180 | +          path: |  | 
 | 181 | +            openmina-docs-${{ steps.version.outputs.version }}.tar.gz  | 
 | 182 | +            openmina-docs-${{ steps.version.outputs.version }}.zip  | 
0 commit comments