Skip to content

Commit 7413b2d

Browse files
committed
Migrate frontend hosting to Cloudflare Workers
1 parent b935ddf commit 7413b2d

7 files changed

Lines changed: 209 additions & 29 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy GitHub Pages
1+
name: Deploy Worker
22

33
on:
44
workflow_run:
@@ -12,20 +12,20 @@ on:
1212

1313
permissions:
1414
contents: read
15-
pages: write
1615
pull-requests: read
17-
id-token: write
1816

1917
concurrency:
20-
group: pages
18+
group: production-worker
2119
cancel-in-progress: false
2220

2321
jobs:
24-
25-
build:
26-
name: Build site
22+
deploy:
23+
name: Deploy Worker
2724
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
2825
runs-on: ubuntu-latest
26+
environment:
27+
name: production
28+
url: https://ridecontrol.xyz
2929
steps:
3030
- name: Check out verified revision
3131
uses: actions/checkout@v7
@@ -35,8 +35,6 @@ jobs:
3535
uses: oven-sh/setup-bun@v2
3636
with:
3737
bun-version: latest
38-
- name: Set up GitHub Pages
39-
uses: actions/configure-pages@v6
4038
- name: Install dependencies
4139
run: bun install --frozen-lockfile
4240
- name: Resolve build metadata
@@ -50,21 +48,11 @@ jobs:
5048
build_pr_url="https://github.com/${GITHUB_REPOSITORY}/pulls?q=is%3Apr+is%3Aclosed"
5149
fi
5250
echo "VITE_BUILD_PR_URL=${build_pr_url}" >> "$GITHUB_ENV"
53-
- name: Build site
51+
- name: Build Worker
5452
run: bun run build
55-
- name: Upload site artifact
56-
uses: actions/upload-pages-artifact@v5
53+
- name: Deploy Worker
54+
uses: cloudflare/wrangler-action@v3
5755
with:
58-
path: dist
59-
60-
deploy:
61-
name: Deploy site
62-
needs: build
63-
runs-on: ubuntu-latest
64-
environment:
65-
name: github-pages
66-
url: ${{ steps.deployment.outputs.page_url }}
67-
steps:
68-
- name: Deploy to GitHub Pages
69-
id: deployment
70-
uses: actions/deploy-pages@v5
56+
accountId: c1e6e1378d9461aa07039950b1bf8b89
57+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
58+
command: deploy

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
node_modules/
22
dist/
3+
.wrangler/
4+
.dev.vars
5+
.dev.vars.*
6+
!.dev.vars.example
37
.DS_Store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ and repeated dialog and keyboard behavior so those rules stay consistent across
7575

7676
Pull requests and pushes to `main` run the complete `bun run ci` suite in GitHub Actions. After
7777
CI succeeds on `main`, a separate workflow runs `bun run build` and deploys the generated `dist`
78-
directory to GitHub Pages at [ridecontrol.xyz](https://ridecontrol.xyz).
78+
assets to a Cloudflare Worker at [ridecontrol.xyz](https://ridecontrol.xyz).
7979

8080
## Automatic reconnect
8181

bun.lock

Lines changed: 169 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"test": "bun test",
1212
"tailwind:check": "bun scripts/check-tailwind.ts",
1313
"ci": "biome check . && bun run tailwind:check && bun test && tsc --noEmit && vite build",
14+
"deploy": "bun run build && wrangler deploy",
1415
"preview": "vite preview --host localhost --port 4200"
1516
},
1617
"dependencies": {
@@ -29,6 +30,7 @@
2930
},
3031
"devDependencies": {
3132
"@biomejs/biome": "^2.5.4",
33+
"@cloudflare/vite-plugin": "^1.45.1",
3234
"@tailwindcss/language-server": "^0.16.0",
3335
"@types/bun": "^1.3.14",
3436
"@types/leaflet": "^1.9.21",
@@ -38,6 +40,7 @@
3840
"@xmldom/xmldom": "^0.9.10",
3941
"typescript": "^7.0.2",
4042
"ultracite": "^7.9.4",
41-
"vite": "^8.1.5"
43+
"vite": "^8.1.5",
44+
"wrangler": "^4.112.0"
4245
}
4346
}

vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cloudflare } from '@cloudflare/vite-plugin';
12
import tailwindcss from '@tailwindcss/vite';
23
import react from '@vitejs/plugin-react';
34
import { defineConfig } from 'vite';
@@ -12,5 +13,5 @@ export default defineConfig({
1213
'import.meta.env.RIDE_CONTROL_BUILD_PR_URL': JSON.stringify(buildPrUrl),
1314
'import.meta.env.RIDE_CONTROL_BUILD_TIMESTAMP_UTC': JSON.stringify(buildTimestampUtc),
1415
},
15-
plugins: [react(), tailwindcss()],
16+
plugins: [react(), tailwindcss(), cloudflare()],
1617
});

wrangler.jsonc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "./node_modules/wrangler/config-schema.json",
3+
"name": "ridecontrol-frontend",
4+
"account_id": "c1e6e1378d9461aa07039950b1bf8b89",
5+
"compatibility_date": "2026-07-21",
6+
"workers_dev": false,
7+
"routes": [
8+
{
9+
"pattern": "ridecontrol.xyz",
10+
"custom_domain": true
11+
}
12+
],
13+
"assets": {
14+
"not_found_handling": "single-page-application"
15+
}
16+
}

0 commit comments

Comments
 (0)