Files

69 lines
2.0 KiB
YAML

name: CI
# Typecheck / test / build on every push & PR; deploy the SPA to Cloudflare
# Workers (static assets) on pushes to main.
#
# Required GitHub config (Settings → Secrets and variables → Actions):
# Variable VITE_API_BASE_URL — Laravel API base URL baked into the build
# Secret CLOUDFLARE_API_TOKEN — token with "Edit Cloudflare Workers" scope
# Secret CLOUDFLARE_ACCOUNT_ID — Cloudflare account id
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Typecheck, test & build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run generate-routes
- run: pnpm run typecheck
- run: pnpm test
- run: pnpm run build
env:
VITE_API_BASE_URL: ${{ vars.VITE_API_BASE_URL }}
deploy:
name: Deploy to Cloudflare Workers
needs: check
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run generate-routes
# cf:build runs `vite build` then copies the TanStack Start SPA shell
# (_shell.html) to index.html so Cloudflare's single-page-application
# fallback (wrangler.jsonc) returns it for every client route.
- name: Build SPA
run: pnpm run cf:build
env:
VITE_API_BASE_URL: ${{ vars.VITE_API_BASE_URL }}
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}