Skip to content

feat(auth): connect Better Auth Infrastructure dashboard (#103) #4

feat(auth): connect Better Auth Infrastructure dashboard (#103)

feat(auth): connect Better Auth Infrastructure dashboard (#103) #4

# Apply pending D1 migrations to production (apps/auth) on merge to main.
#
# Split from d1-migrations.yml so auth-only changes don't trigger the apps/api
# apply job and vice versa — the two apps have independent D1 databases and
# migration histories. Replay-safe: wrangler skips rows already recorded in
# d1_migrations.
#
# Secrets (same as headless deploy): CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID.
# Token needs D1 edit in addition to Workers (Edit Cloudflare Workers template
# alone is not always enough — add D1 write if apply fails with auth errors).
name: D1 Migrations (auth)
on:
push:
branches: [main]
paths:
- "apps/auth/migrations/**"
- "apps/auth/wrangler.jsonc"
- ".github/workflows/d1-migrations-auth.yml"
workflow_dispatch:
concurrency:
group: d1-migrations-auth-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
apply-auth:
name: Apply D1 migrations (auth, production)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
cache: pnpm
# Workspace install so apps/auth resolves its wrangler devDependency.
- run: pnpm install --frozen-lockfile
# Binding name `DB` (see apps/auth/wrangler.jsonc) — a separate D1
# database (uploads-auth) from apps/api's, per plan D1. Non-interactive
# CI skips the confirmation prompt; already-applied migrations are no-ops.
- name: Apply D1 migrations
working-directory: apps/auth
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: pnpm exec wrangler d1 migrations apply DB --remote