4.0 KiB
4.0 KiB
Gitea to Cloudflare Workers — Linear Void
Goal
Deploy the Linear Void frontend (Vite + TypeScript SPA) from Gitea to Cloudflare Workers using Gitea Actions and Wrangler.
Prerequisites
- Cloudflare Worker for the SPA:
- Dashboard → Workers & Pages → Create → Worker (or Workers Static Assets).
- Name it
linearvoid-frontend(the edge-cache Worker already uses thelinearvoidname).
- API token with Workers permissions:
- Create at https://dash.cloudflare.com/profile/api-tokens
- Permission:
Account → Workers Scripts → EditandAccount → Workers Routes → Edit - Store in Gitea → Settings → Secrets as
CLOUDFLARE_API_TOKEN
- Account ID from Cloudflare dashboard overview → store as
CLOUDFLARE_ACCOUNT_ID - Wrangler config (
frontend/wrangler.toml) binding thefrontend/distoutput as static assets.
Naming conflict: Workers share a namespace under "Workers & Pages". The edge-cache Worker (
infrastructure/cloudflare/worker.js) already uses thelinearvoidname, so the SPA Worker is namedlinearvoid-frontend(seefrontend/wrangler.toml).
Project-specific values
| Setting | Value |
|---|---|
| Framework | Vite + TypeScript |
| Build command | cd frontend && npm install && npm run build |
| Output directory | frontend/dist |
| Node version | 22 |
| Multi-page entries | index.html, admin/index.html, admin/login/index.html |
Gitea Actions workflow
Build the SPA and deploy with Wrangler:
name: Deploy to Cloudflare Workers
on:
workflow_run:
workflows: [CI]
types: [completed]
workflow_dispatch: {}
jobs:
deploy:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: cd frontend && npm ci
- name: Build
run: cd frontend && npm run build
- name: Deploy to Cloudflare Workers
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
cd frontend
npx wrangler deploy
Secrets to add in Gitea
| Secret | Value |
|---|---|
CLOUDFLARE_API_TOKEN |
API token with Workers permissions |
CLOUDFLARE_ACCOUNT_ID |
Cloudflare account ID from dashboard |
Verify deployment
- Push to
mainor trigger manually from Gitea Actions. - Check Gitea Actions → job logs for the deploy step.
- Check Cloudflare Workers →
linearvoid-frontend→ Deployments for the new version. - Visit
https://linearvoid-frontend.zwitschi82.workers.dev, then attachlinearvoid.tvwhen ready.
Notes
- The existing
ci.ymlalready builds the frontend; the Workers deploy workflow is additive and independent. - Multi-page SPA (
vite.config.ts) produces three entry points — Workers static assets serve them correctly. - For SPA fallback routing, set Workers static assets
not_found_handlingtosingle-page-application(serveindex.htmlfor unknown paths). - The deploy workflow lives in
.gitea/workflows/workers-deploy.yml(triggered after CI succeeds).
Related resources
- Cloudflare Workers dashboard:
https://dash.cloudflare.com/deb11491c54ec53a24772e98ac6d8128/workers/services/view/linearvoid/production/settings— for managing theinfrastructure/cloudflare/worker.jsdeployment and the SPA Worker