fix 404 #17
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: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install TinyGo | |
| run: | | |
| wget -q https://github.com/tinygo-org/tinygo/releases/download/v0.40.1/tinygo_0.40.1_amd64.deb -O /tmp/tinygo.deb | |
| sudo dpkg -i /tmp/tinygo.deb | |
| - name: Build WASM | |
| run: | | |
| GOOS=js GOARCH=wasm go build -ldflags="-s -w" -trimpath -o gnata.wasm ./wasm/ | |
| cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" wasm_exec.js | |
| tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -target wasm ./editor/ | |
| cp "$(tinygo env TINYGOROOT)/targets/wasm_exec.js" lsp-wasm_exec.js | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build React widget | |
| run: cd react && pnpm run build | |
| # Build docs site (Fumadocs static export) | |
| - name: Copy WASM to website | |
| run: cp gnata.wasm gnata-lsp.wasm wasm_exec.js lsp-wasm_exec.js website/public/ | |
| - name: Build website | |
| run: cd website && pnpm build | |
| env: | |
| GITHUB_PAGES: true | |
| # Build playground (Vite static build) | |
| - name: Copy WASM to playground | |
| run: cp gnata.wasm gnata-lsp.wasm wasm_exec.js lsp-wasm_exec.js playground/public/ | |
| - name: Build playground | |
| run: cd playground && pnpm build | |
| env: | |
| GITHUB_PAGES: true | |
| # Combine: docs site at root, playground nested at /playground/ | |
| - name: Assemble site | |
| run: | | |
| mkdir -p _site | |
| cp -r website/out/* _site/ | |
| mkdir -p _site/playground | |
| cp -r playground/dist/* _site/playground/ | |
| # SPA fallback for playground routes | |
| # GitHub Pages only checks root 404.html, so use a redirect | |
| cat > _site/404.html << 'FOUROHFOUR' | |
| <!DOCTYPE html><html><head><meta charset="utf-8"><script> | |
| var p = window.location.pathname; | |
| if (p.startsWith('/gnata-sqlite/playground')) { | |
| var base = '/gnata-sqlite/playground/'; | |
| var route = p.slice(base.length); | |
| window.location.replace(base + '?route=' + encodeURIComponent(route) + window.location.hash); | |
| } | |
| </script></head><body></body></html> | |
| FOUROHFOUR | |
| - uses: actions/upload-pages-artifact@v3 | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deploy.outputs.page_url }} | |
| steps: | |
| - id: deploy | |
| uses: actions/deploy-pages@v4 |