mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
130 lines
3.9 KiB
YAML
130 lines
3.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, staging]
|
|
pull_request:
|
|
branches: [main, staging]
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
test:
|
|
name: Test and Build
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: latest
|
|
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Run tests with coverage
|
|
env:
|
|
NODE_OPTIONS: '--no-warnings'
|
|
NEXT_PUBLIC_APP_URL: 'https://www.sim.ai'
|
|
DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/simstudio'
|
|
ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only
|
|
run: bun run test
|
|
|
|
- name: Build application
|
|
env:
|
|
NODE_OPTIONS: '--no-warnings'
|
|
NEXT_PUBLIC_APP_URL: 'https://www.sim.ai'
|
|
DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/simstudio'
|
|
STRIPE_SECRET_KEY: 'dummy_key_for_ci_only'
|
|
STRIPE_WEBHOOK_SECRET: 'dummy_secret_for_ci_only'
|
|
RESEND_API_KEY: 'dummy_key_for_ci_only'
|
|
AWS_REGION: 'us-west-2'
|
|
ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only
|
|
run: bun run build
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
directory: ./apps/sim/coverage
|
|
fail_ci_if_error: false
|
|
verbose: true
|
|
|
|
# Main branch: build (ECR + GHCR)
|
|
build:
|
|
name: Build (ECR + GHCR)
|
|
needs: test
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
uses: ./.github/workflows/build.yml
|
|
secrets: inherit
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
|
|
# Staging branch: ECR only
|
|
build-ecr-deploy:
|
|
name: Build ECR and Deploy (Staging)
|
|
needs: test
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/staging'
|
|
uses: ./.github/workflows/build-ecr.yml
|
|
secrets: inherit
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
|
|
# Call Trigger.dev deploy workflow (runs in parallel)
|
|
trigger-deploy:
|
|
name: Deploy Trigger.dev
|
|
needs: test
|
|
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
|
|
uses: ./.github/workflows/trigger-deploy.yml
|
|
secrets: inherit
|
|
|
|
# Run database migrations (depends on build completion and trigger deployment)
|
|
migrations:
|
|
name: Apply Database Migrations
|
|
needs: [build-ecr-deploy, build, trigger-deploy]
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
if: |
|
|
always() &&
|
|
github.event_name == 'push' &&
|
|
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') &&
|
|
(needs.build-ecr-deploy.result == 'success' || needs.build.result == 'success') &&
|
|
needs.trigger-deploy.result == 'success'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Install dependencies
|
|
run: bun install
|
|
|
|
- name: Apply migrations
|
|
working-directory: ./packages/db
|
|
env:
|
|
DATABASE_URL: ${{ github.ref == 'refs/heads/main' && secrets.DATABASE_URL || secrets.STAGING_DATABASE_URL }}
|
|
run: bunx drizzle-kit migrate --config=./drizzle.config.ts
|
|
|
|
# Process docs embeddings if needed
|
|
process-docs:
|
|
name: Process Docs
|
|
needs: migrations
|
|
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
|
|
uses: ./.github/workflows/docs-embeddings.yml
|
|
secrets: inherit
|