From cf3700a9edc743756de1b87cc5b331ef589d37a7 Mon Sep 17 00:00:00 2001 From: Donald Ng Date: Sat, 17 Oct 2026 21:45:45 +0800 Subject: [PATCH 1/3] Deploy the docs to Cloudflare instead of Vercel wrangler.toml serves the Docusaurus build as static assets from a Cloudflare Worker. The GitHub Actions workflow deploys main to production and gives each pull request its own preview URL. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/deploy.yml | 57 ++++++++++++++++++++++++++++++++++++ wrangler.toml | 11 +++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 wrangler.toml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..82628d1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,57 @@ +# Builds the docs and deploys them to Cloudflare (see wrangler.toml). +# push to main -> production, docs.mida.so +# pull request -> a preview URL, posted as a comment on the PR +name: Deploy docs + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: deploy-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy: + # pull requests from forks don't get the Cloudflare secrets, so they only build + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - run: npm run build + + - name: Deploy to docs.mida.so + if: github.event_name == 'push' + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: deploy + + - name: Upload preview + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: versions upload --preview-alias pr-${{ github.event.pull_request.number }} + + - name: Comment the preview URL + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + uses: actions/github-script@v7 + with: + script: | + const url = `https://pr-${context.issue.number}-mida-docs.donald-929.workers.dev`; + const body = `Preview of this pull request: ${url}\n\n(updated for ${context.sha.slice(0, 7)})`; + const { data: comments } = await github.rest.issues.listComments({ ...context.repo, issue_number: context.issue.number }); + const mine = comments.find(c => c.user.type === 'Bot' && c.body.startsWith('Preview of this pull request')); + if (mine) await github.rest.issues.updateComment({ ...context.repo, comment_id: mine.id, body }); + else await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body }); diff --git a/wrangler.toml b/wrangler.toml new file mode 100644 index 0000000..d95cfd0 --- /dev/null +++ b/wrangler.toml @@ -0,0 +1,11 @@ +# docs.mida.so: the Docusaurus build served as static assets by a Cloudflare Worker (free: static asset requests aren't billed). +# Deploys from GitHub Actions (.github/workflows/deploy.yml): main -> production, pull requests -> preview URL. +name = "mida-docs" +compatibility_date = "2026-10-01" +workers_dev = true +preview_urls = true + +[assets] +directory = "./build" +html_handling = "drop-trailing-slash" +not_found_handling = "404-page" From 51f9268fd486eb86c81973c5b6636bebbb2e4e4c Mon Sep 17 00:00:00 2001 From: Donald Ng Date: Sat, 17 Oct 2026 21:48:53 +0800 Subject: [PATCH 2/3] Pin wrangler so preview uploads support --preview-alias Co-Authored-By: Claude Opus 5.5 --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 82628d1..f425f28 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,6 +34,7 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + wranglerVersion: '4.86.0' command: deploy - name: Upload preview @@ -42,6 +43,7 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + wranglerVersion: '4.86.0' command: versions upload --preview-alias pr-${{ github.event.pull_request.number }} - name: Comment the preview URL From a05f31a13503787028c6c5a5ff4d3e4cca82aa0c Mon Sep 17 00:00:00 2001 From: Donald Ng Date: Sat, 17 Oct 2026 21:52:20 +0800 Subject: [PATCH 3/3] Serve the production deploy on docs.mida.so Co-Authored-By: Claude Opus 5.5 --- wrangler.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/wrangler.toml b/wrangler.toml index d95cfd0..fb9d85d 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -4,6 +4,7 @@ name = "mida-docs" compatibility_date = "2026-10-01" workers_dev = true preview_urls = true +routes = [{ pattern = "docs.mida.so", custom_domain = true }] [assets] directory = "./build"