Skip to content

Commit 01a04db

Browse files
tlgimenesclaude
andauthored
feat(docs): migrate from Deco deploy to Cloudflare Pages (#2659)
- Replace Cloudflare Workers server with native Pages routing via _redirects - Remove wrangler.toml, server/, and deco-cli dependencies - Simplify Astro config and build scripts - Update GitHub Actions workflow to use wrangler pages deploy - Uses existing CF_API_TOKEN and CF_ACCOUNT_ID secrets The docs site is now pure static Astro built with Cloudflare Pages, eliminating the worker resource limit issues. Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 73117e0 commit 01a04db

6 files changed

Lines changed: 28 additions & 127 deletions

File tree

.github/workflows/deploy-docs.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ jobs:
1818
- name: Set up Bun
1919
uses: oven-sh/setup-bun@v2
2020

21-
- name: Install Deco CLI
22-
run: bun install -g deco-cli
23-
2421
- name: Install dependencies
2522
run: bun install
2623

27-
- name: Deploy
28-
run: bun run deploy
24+
- name: Build
25+
run: bun run build
26+
working-directory: apps/docs
27+
28+
- name: Deploy to Cloudflare Pages
29+
run: wrangler pages deploy dist/client --project-name=decocms-docs
2930
working-directory: apps/docs
3031
env:
31-
DECO_DEPLOY_TOKEN: ${{ secrets.DECO_DEPLOY_TOKEN_DOCS }}
32+
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
33+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}

apps/docs/astro.config.mjs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,21 @@
11
// @ts-check
22
import { defineConfig } from "astro/config";
33
import tailwindcss from "@tailwindcss/vite";
4-
import { unlink } from "node:fs/promises";
5-
import { join } from "node:path";
64

75
import mdx from "@astrojs/mdx";
86

97
import react from "@astrojs/react";
108

11-
/**
12-
* Patches the CSR redirect to delete the root index files.
13-
* @returns {import("astro").AstroIntegration}
14-
*/
15-
function patchCsrRedirect() {
16-
return {
17-
name: "patch-csr-redirect",
18-
hooks: {
19-
"astro:build:done": async ({ dir }) => {
20-
const filesToDelete = [
21-
"index.html",
22-
"en/index.html",
23-
"pt-br/index.html",
24-
];
25-
for (const file of filesToDelete) {
26-
try {
27-
await unlink(join(dir.pathname, file));
28-
console.log(`[CSR Redirect Patch] Deleted ${file}`);
29-
} catch {
30-
// File may not exist, ignore
31-
}
32-
}
33-
},
34-
},
35-
};
36-
}
37-
389
// https://astro.build/config
3910
export default defineConfig({
4011
root: "client",
4112
server: {
4213
port: 4000,
4314
},
44-
redirects: {
45-
"/": "/2026-03-10/en/mcp-mesh/quickstart",
46-
},
4715
outDir: "dist/client/",
16+
publicDir: "client/public",
4817
srcDir: "client/src",
49-
integrations: [mdx(), react(), patchCsrRedirect()],
18+
integrations: [mdx(), react()],
5019
vite: {
5120
plugins: [
5221
// @ts-ignore: tailwindcss plugin type issue

apps/docs/client/public/_redirects

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Root redirects
2+
/ /2026-03-10/en/mcp-mesh/quickstart 302
3+
/latest /2026-03-10/en/mcp-mesh/quickstart 302
4+
/2026-03-10 /2026-03-10/en/mcp-mesh/quickstart 302
5+
/2025-10-10 /2025-10-10/en/introduction 302
6+
/en /2026-03-10/en/mcp-mesh/quickstart 302
7+
/pt-br /2026-03-10/pt-br/mcp-mesh/quickstart 302
8+
/2026-03-10/en /2026-03-10/en/mcp-mesh/quickstart 302
9+
/2026-03-10/pt-br /2026-03-10/pt-br/mcp-mesh/quickstart 302
10+
/2025-10-10/en /2025-10-10/en/introduction 302
11+
/2025-10-10/pt-br /2025-10-10/pt-br/introduction 302
12+
13+
# Rewrite /latest/* to current version
14+
/latest/* /2026-03-10/:splat 302

apps/docs/package.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33
"version": "1.0.0",
44
"description": "DecoCMS documentation",
55
"scripts": {
6-
"dev": "concurrently \"bun run dev:client\" \"NODE_ENV=development bun --hot run server/main.ts\"",
7-
"dev:client": "astro dev",
8-
"dev:tunnel": "deco link -p 3000 -- bun run dev",
9-
"build": "bun run build:client && bun run build:server:wrangler",
10-
"build:client": "astro build",
6+
"dev": "astro dev",
7+
"build": "astro build",
118
"check": "astro sync > /dev/null 2>&1 && tsc --noEmit",
12-
"build:server:bun": "NODE_ENV=production bun build server/main.ts --target=bun --outfile=dist/server/main.js",
13-
"build:server:wrangler": "wrangler build && mkdir -p dist/server && mv ./dist/main.js dist/server/main.js",
14-
"start": "NODE_ENV=production bun run dist/server/main.js",
15-
"deploy": "bun run build && deco deploy ./dist/server -y -f -t $DECO_DEPLOY_TOKEN",
16-
"gen": "deco gen --output=shared/deco.gen.ts",
9+
"deploy": "bun run build && wrangler pages deploy dist/client --project-name=decocms-docs",
1710
"astro": "astro"
1811
},
1912
"dependencies": {
@@ -25,13 +18,10 @@
2518
"react": "^19.2.0",
2619
"react-dom": "^19.1.0",
2720
"tailwindcss": "^4.0.7",
28-
"typescript": "^5.9.3",
29-
"@decocms/runtime": "workspace:*"
21+
"typescript": "^5.9.3"
3022
},
3123
"devDependencies": {
3224
"@tailwindcss/typography": "^0.5.16",
33-
"concurrently": "^9.2.1",
34-
"deco-cli": "^0.28.0",
3525
"typescript": "^5.9.3",
3626
"wrangler": "^4.40.3"
3727
},

apps/docs/server/main.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

apps/docs/wrangler.toml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)