Skip to content

Skip billing for missing customers/orgs #52

Skip billing for missing customers/orgs

Skip billing for missing customers/orgs #52

Workflow file for this run

name: Deploy API
on:
push:
branches: [main]
paths:
- 'apps/api/**'
- 'packages/contract/**'
- 'packages/db/**'
- 'packages/config/**'
- 'fly.toml'
- 'package.json'
- 'bun.lock'
- '.github/workflows/deploy-api.yml'
workflow_dispatch:
inputs:
stage:
description: Deployment stage
required: true
default: dev
type: choice
options:
- dev
- production
concurrency:
group: deploy-api-${{ inputs.stage || 'production' }}
cancel-in-progress: false
jobs:
check:
name: Typecheck & Test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install --frozen-lockfile
- name: Build dependencies
run: bun run --filter @sandchest/contract build && bun run --filter @sandchest/db build
- name: Typecheck API
run: bun run --filter @sandchest/api typecheck
- name: Test API
run: bun run --filter @sandchest/api test
env:
DATABASE_URL: mysql://test:test@localhost:3306/test
BETTER_AUTH_SECRET: test-secret-for-ci-only-not-real
RESEND_API_KEY: re_test_000000000000000000000000
migrate:
name: Run Database Migrations
needs: check
runs-on: ubuntu-latest
timeout-minutes: 5
environment: production
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install --frozen-lockfile
- name: Validate secrets
run: |
if [ -z "$DATABASE_URL" ]; then
echo "::error::DATABASE_URL secret is not set. Add it to repo Settings → Secrets or the 'production' environment."
exit 1
fi
echo "DATABASE_URL is set (${#DATABASE_URL} chars)"
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Run database migrations
run: bun run db:migrate:run
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
deploy:
name: Deploy to Fly.io
needs: migrate
runs-on: ubuntu-latest
timeout-minutes: 15
environment: production
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy to Fly.io
run: flyctl deploy --remote-only
env:
FLY_ACCESS_TOKEN: ${{ secrets.FLY_ACCESS_TOKEN }}
- name: Verify deployment
run: |
sleep 10
flyctl status -a sandchest-api
env:
FLY_ACCESS_TOKEN: ${{ secrets.FLY_ACCESS_TOKEN }}