|
6 | 6 | pull_request: |
7 | 7 | branches: [main, staging] |
8 | 8 |
|
| 9 | +concurrency: |
| 10 | + group: ci-${{ github.ref }} |
| 11 | + cancel-in-progress: false |
| 12 | + |
9 | 13 | jobs: |
10 | | - test: |
| 14 | + test-build: |
11 | 15 | name: Test and Build |
12 | | - runs-on: ubuntu-latest |
13 | | - |
14 | | - steps: |
15 | | - - name: Checkout code |
16 | | - uses: actions/checkout@v4 |
17 | | - |
18 | | - - name: Setup Bun |
19 | | - uses: oven-sh/setup-bun@v2 |
20 | | - with: |
21 | | - bun-version: latest |
22 | | - |
23 | | - - name: Setup Node |
24 | | - uses: actions/setup-node@v4 |
25 | | - with: |
26 | | - node-version: latest |
27 | | - |
28 | | - - name: Install dependencies |
29 | | - run: bun install --frozen-lockfile |
30 | | - |
31 | | - - name: Run tests with coverage |
32 | | - env: |
33 | | - NODE_OPTIONS: '--no-warnings' |
34 | | - NEXT_PUBLIC_APP_URL: 'https://www.sim.ai' |
35 | | - DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/simstudio' |
36 | | - ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only |
37 | | - run: bun run test |
| 16 | + uses: ./.github/workflows/test-build.yml |
| 17 | + secrets: inherit |
38 | 18 |
|
39 | | - - name: Build application |
40 | | - env: |
41 | | - NODE_OPTIONS: '--no-warnings' |
42 | | - NEXT_PUBLIC_APP_URL: 'https://www.sim.ai' |
43 | | - DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/simstudio' |
44 | | - STRIPE_SECRET_KEY: 'dummy_key_for_ci_only' |
45 | | - STRIPE_WEBHOOK_SECRET: 'dummy_secret_for_ci_only' |
46 | | - RESEND_API_KEY: 'dummy_key_for_ci_only' |
47 | | - AWS_REGION: 'us-west-2' |
48 | | - ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only |
49 | | - run: bun run build |
50 | | - |
51 | | - - name: Upload coverage to Codecov |
52 | | - uses: codecov/codecov-action@v5 |
53 | | - with: |
54 | | - directory: ./apps/sim/coverage |
55 | | - fail_ci_if_error: false |
56 | | - verbose: true |
| 19 | + # Build and push images (ECR for staging, ECR + GHCR for main) |
| 20 | + build-images: |
| 21 | + name: Build Images |
| 22 | + needs: test-build |
| 23 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') |
| 24 | + uses: ./.github/workflows/images.yml |
| 25 | + secrets: inherit |
| 26 | + permissions: |
| 27 | + contents: read |
| 28 | + packages: write |
| 29 | + id-token: write |
| 30 | + |
| 31 | + # Deploy Trigger.dev (after builds complete) |
| 32 | + trigger-deploy: |
| 33 | + name: Deploy Trigger.dev |
| 34 | + needs: build-images |
| 35 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') |
| 36 | + uses: ./.github/workflows/trigger-deploy.yml |
| 37 | + secrets: inherit |
57 | 38 |
|
| 39 | + # Run database migrations (depends on build completion and trigger deployment) |
58 | 40 | migrations: |
59 | 41 | name: Apply Database Migrations |
60 | | - runs-on: ubuntu-latest |
| 42 | + needs: [build-images, trigger-deploy] |
| 43 | + if: | |
| 44 | + always() && |
| 45 | + github.event_name == 'push' && |
| 46 | + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') && |
| 47 | + needs.build-images.result == 'success' && |
| 48 | + needs.trigger-deploy.result == 'success' |
| 49 | + uses: ./.github/workflows/migrations.yml |
| 50 | + secrets: inherit |
| 51 | + |
| 52 | + # Process docs embeddings if needed |
| 53 | + process-docs: |
| 54 | + name: Process Docs |
| 55 | + needs: migrations |
61 | 56 | if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') |
62 | | - needs: test |
63 | | - steps: |
64 | | - - name: Checkout code |
65 | | - uses: actions/checkout@v4 |
66 | | - |
67 | | - - name: Setup Bun |
68 | | - uses: oven-sh/setup-bun@v2 |
69 | | - with: |
70 | | - bun-version: latest |
71 | | - |
72 | | - - name: Install dependencies |
73 | | - run: bun install |
74 | | - |
75 | | - - name: Apply migrations |
76 | | - working-directory: ./packages/db |
77 | | - env: |
78 | | - DATABASE_URL: ${{ github.ref == 'refs/heads/main' && secrets.DATABASE_URL || secrets.STAGING_DATABASE_URL }} |
79 | | - run: bunx drizzle-kit migrate --config=./drizzle.config.ts |
| 57 | + uses: ./.github/workflows/docs-embeddings.yml |
| 58 | + secrets: inherit |
0 commit comments