Skip to content

Commit dc33b3a

Browse files
committed
feat: enhance deployment in cloudflare
1 parent 050102c commit dc33b3a

11 files changed

Lines changed: 64 additions & 134 deletions

File tree

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Cross-app URLs — used by navbar links
2+
# In production, these default to subdomains (see packages/ui/src/lib/app-links.ts)
3+
# Override here for local development
4+
PUBLIC_WEBSITE_URL=http://localhost:4323
5+
PUBLIC_DOCS_URL=http://localhost:4321
6+
PUBLIC_BLOG_URL=http://localhost:4322

.github/workflows/deploy-blog.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
- run: pnpm install --frozen-lockfile
2828

2929
- run: pnpm --filter @explainer/blog build
30+
env:
31+
PUBLIC_BLOG_URL: ${{ vars.PUBLIC_BLOG_URL }}
32+
PUBLIC_DOCS_URL: ${{ vars.PUBLIC_DOCS_URL }}
33+
PUBLIC_WEBSITE_URL: ${{ vars.PUBLIC_WEBSITE_URL }}
3034

3135
- uses: actions/upload-artifact@v4
3236
with:

.github/workflows/deploy-docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
- run: pnpm install --frozen-lockfile
2626

2727
- run: pnpm --filter @explainer/docs build
28+
env:
29+
PUBLIC_DOCS_URL: ${{ vars.PUBLIC_DOCS_URL }}
30+
PUBLIC_BLOG_URL: ${{ vars.PUBLIC_BLOG_URL }}
31+
PUBLIC_WEBSITE_URL: ${{ vars.PUBLIC_WEBSITE_URL }}
2832

2933
- uses: actions/upload-artifact@v4
3034
with:

.github/workflows/deploy-website.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
- run: pnpm install --frozen-lockfile
2626

2727
- run: pnpm --filter @explainer/website build
28+
env:
29+
PUBLIC_WEBSITE_URL: ${{ vars.PUBLIC_WEBSITE_URL }}
30+
PUBLIC_DOCS_URL: ${{ vars.PUBLIC_DOCS_URL }}
31+
PUBLIC_BLOG_URL: ${{ vars.PUBLIC_BLOG_URL }}
2832

2933
- uses: actions/upload-artifact@v4
3034
with:

apps/blog/astro.config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readFileSync } from 'node:fs'
12
import { defineConfig } from 'astro/config'
23
import react from '@astrojs/react'
34
import mdx from '@astrojs/mdx'
@@ -9,8 +10,24 @@ import { remarkDirectiveHandler } from '@explainer/mdx/remark-directive-handler'
910
import { remarkCodeBlocks } from '@explainer/mdx/remark-code-blocks'
1011
import { thumbnailIntegration } from '@explainer/thumbnail/integration'
1112

13+
function loadRootEnv() {
14+
try {
15+
const content = readFileSync('../../.env', 'utf-8')
16+
const env: Record<string, string> = {}
17+
for (const line of content.split('\n')) {
18+
const match = line.match(/^\s*([\w.]+)\s*=\s*(.*)?\s*$/)
19+
if (match) env[match[1]] = match[2]?.replace(/^['"]|['"]$/g, '') ?? ''
20+
}
21+
return env
22+
} catch {
23+
return {}
24+
}
25+
}
26+
27+
const env = loadRootEnv()
28+
1229
export default defineConfig({
13-
site: 'https://blog.example.com',
30+
site: process.env.PUBLIC_BLOG_URL || env.PUBLIC_BLOG_URL,
1431
i18n: {
1532
locales: ['en', 'fr'],
1633
defaultLocale: 'en',

apps/blog/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@
99
"preview": "astro preview"
1010
},
1111
"dependencies": {
12-
"astro": "^5.5.0",
13-
"@astrojs/react": "^4.2.0",
1412
"@astrojs/mdx": "^4.2.0",
13+
"@astrojs/react": "^4.2.0",
1514
"@astrojs/rss": "^4.0.0",
16-
"@tailwindcss/vite": "^4.0.0",
17-
"tailwindcss": "^4.0.0",
18-
"react": "^19.0.0",
19-
"react-dom": "^19.0.0",
20-
"@explainer/ui": "workspace:*",
2115
"@explainer/mdx": "workspace:*",
2216
"@explainer/thumbnail": "workspace:*",
17+
"@explainer/ui": "workspace:*",
2318
"@iconify/react": "^5.2.0",
24-
"remark-directive": "^4.0.0"
19+
"@tailwindcss/vite": "^4.0.0",
20+
"astro": "^5.5.0",
21+
"react": "^19.0.0",
22+
"react-dom": "^19.0.0",
23+
"remark-directive": "^4.0.0",
24+
"tailwindcss": "^4.0.0"
2525
},
2626
"devDependencies": {
27+
"@types/node": "^25.5.0",
2728
"@types/react": "^19.0.0",
2829
"@types/react-dom": "^19.0.0",
2930
"typescript": "^5.8.0"

apps/docs/astro.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { remarkCodeBlocks } from '@explainer/mdx/remark-code-blocks'
1010
import { thumbnailIntegration } from '@explainer/thumbnail/integration'
1111

1212
export default defineConfig({
13+
site: process.env.PUBLIC_DOCS_URL || undefined,
1314
devToolbar: { enabled: false },
1415
integrations: [
1516
react(),

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"tailwindcss": "^4.0.0"
2424
},
2525
"devDependencies": {
26+
"@types/node": "^25.5.0",
2627
"@types/react": "^19.0.0",
2728
"@types/react-dom": "^19.0.0",
2829
"pagefind": "^1.4.0",

apps/website/astro.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import tailwindcss from '@tailwindcss/vite'
44
import { thumbnailIntegration } from '@explainer/thumbnail/integration'
55

66
export default defineConfig({
7+
site: process.env.PUBLIC_WEBSITE_URL || undefined,
78
integrations: [
89
react(),
910
thumbnailIntegration({

apps/website/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
"preview": "astro preview"
1010
},
1111
"dependencies": {
12-
"astro": "^5.5.0",
1312
"@astrojs/react": "^4.2.0",
13+
"@explainer/thumbnail": "workspace:*",
14+
"@explainer/ui": "workspace:*",
15+
"@iconify/react": "^5.2.0",
1416
"@tailwindcss/vite": "^4.0.0",
15-
"tailwindcss": "^4.0.0",
17+
"astro": "^5.5.0",
1618
"react": "^19.0.0",
1719
"react-dom": "^19.0.0",
18-
"@explainer/thumbnail": "workspace:*",
19-
"@explainer/ui": "workspace:*",
20-
"@iconify/react": "^5.2.0"
20+
"tailwindcss": "^4.0.0"
2121
},
2222
"devDependencies": {
23+
"@types/node": "^25.5.0",
2324
"@types/react": "^19.0.0",
2425
"@types/react-dom": "^19.0.0",
2526
"typescript": "^5.8.0"

0 commit comments

Comments
 (0)