refactor: reorganize documentation navigation for users and developers #59
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 (Cloudflare Pages) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - src/** | |
| - public/** | |
| - content/** | |
| - package.json | |
| - pnpm-lock.yaml | |
| - vite.config.ts | |
| - tsconfig.json | |
| - wrangler.jsonc | |
| - .github/workflows/deploy-cloudflare-pages.yml | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: cloudflare-pages-deploy-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| deploy-pages: | |
| name: Deploy Pages (UI) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| name: Install pnpm | |
| with: | |
| version: 10 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| - name: Install dependencies and build | |
| run: pnpm install && pnpm build | |
| env: | |
| NITRO_PRESET: cloudflare_pages | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| - name: Resolve deploy settings | |
| id: cfg | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| node <<'NODE' | |
| const fs = require('node:fs'); | |
| function readJson(path) { | |
| return JSON.parse(fs.readFileSync(path, 'utf8')); | |
| } | |
| const pagesCfgPath = 'wrangler.jsonc'; | |
| const workersCfgPath = 'wrangler.workers.jsonc'; | |
| const pagesCfg = readJson(pagesCfgPath); | |
| const workersCfg = readJson(workersCfgPath); | |
| const pagesName = String(pagesCfg?.name ?? '').trim(); | |
| const workersName = String(workersCfg?.name ?? '').trim(); | |
| if (!pagesName) { | |
| throw new Error('Could not resolve Pages project name from wrangler.jsonc (expected: { "name": "..." })'); | |
| } | |
| if (!workersName) { | |
| throw new Error('Could not resolve Worker name from wrangler.workers.jsonc (expected: { "name": "..." })'); | |
| } | |
| if (pagesName !== workersName) { | |
| throw new Error(`Config mismatch: wrangler.jsonc name="${pagesName}" but wrangler.workers.jsonc name="${workersName}". They must match.`); | |
| } | |
| const accountId = String(process.env.CLOUDFLARE_ACCOUNT_ID ?? '').trim(); | |
| if (!accountId) { | |
| throw new Error('Missing CLOUDFLARE_ACCOUNT_ID (required for Wrangler in CI).'); | |
| } | |
| // Generate CI-only configs that pin account_id so Wrangler does not need to call | |
| // the /memberships endpoint to infer it. | |
| pagesCfg.account_id = accountId; | |
| const ciPagesConfigPath = 'wrangler.pages.ci.json'; | |
| fs.writeFileSync(ciPagesConfigPath, JSON.stringify(pagesCfg, null, 2) + '\n'); | |
| const pagesBaseUrl = `https://${pagesName}.pages.dev`; | |
| const compatibilityDate = String(pagesCfg?.compatibility_date ?? '').trim(); | |
| fs.appendFileSync( | |
| process.env.GITHUB_OUTPUT, | |
| [ | |
| `worker_name=${pagesName}`, | |
| `pages_base_url=${pagesBaseUrl}`, | |
| `compatibility_date=${compatibilityDate}`, | |
| `wrangler_pages_config=${ciPagesConfigPath}`, | |
| '', | |
| ].join('\n'), | |
| ); | |
| console.log(`Project name: ${pagesName}`); | |
| console.log(`Pages base URL: ${pagesBaseUrl}`); | |
| console.log(`Wrangler Pages config: ${ciPagesConfigPath}`); | |
| NODE | |
| - name: Ensure Pages project exists | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| PAGES_PROJECT: ${{ steps.cfg.outputs.worker_name }} | |
| COMPATIBILITY_DATE: ${{ steps.cfg.outputs.compatibility_date }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| project="${PAGES_PROJECT:?PAGES_PROJECT is required}" | |
| compat="${COMPATIBILITY_DATE:-}" | |
| echo "Ensuring Pages project '$project' exists (errors are safe to ignore):" | |
| cmd=(pnpm wrangler pages project create "$project" --production-branch "main") | |
| if [ -n "$compat" ]; then | |
| cmd+=(--compatibility-date "$compat") | |
| fi | |
| "${cmd[@]}" || true | |
| - name: Deploy Pages (UI) | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| PAGES_PROJECT: ${{ steps.cfg.outputs.worker_name }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| project="${PAGES_PROJECT:?PAGES_PROJECT is required}" | |
| echo "Deploying Pages project '$project' from ./dist" | |
| pnpm wrangler pages deploy dist --project-name "$project" --branch "main" --experimental-provision --experimental-auto-create | |
| echo "Pages URL: https://$project.pages.dev" >> "$GITHUB_STEP_SUMMARY" |