Skip to content

Commit 6ca49d5

Browse files
committed
feat(deploy): add Vercel auto-deploy workflows and update guide
- .github/workflows/deploy-marketing.yml: trigger Vercel deploy on marketing changes - .github/workflows/deploy-platform.yml: trigger Vercel deploy + DB migrations on platform changes - docs/infra/deployment.md: rewrite steps for Vercel Dashboard (recommended) vs CLI - vercel.json: correct outputDirectory paths for monorepo builds
1 parent ee127c1 commit 6ca49d5

3 files changed

Lines changed: 133 additions & 11 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Deploy Marketing
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "apps/marketing/**"
8+
- "packages/**"
9+
- "pnpm-lock.yaml"
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: pnpm/action-setup@v3
17+
with: { version: "10.0.0" }
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: "pnpm"
22+
- run: pnpm install --frozen-lockfile
23+
- run: pnpm db:generate
24+
- name: Deploy to Vercel
25+
run: |
26+
echo "Deploy marketing via Vercel Git integration"
27+
curl -X POST "https://api.vercel.com/v1/integrations/deploy/${{ secrets.VERCEL_PROJECT_ID_MARKETING }}" \
28+
-H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \
29+
-d '{"buildCache": true}' || echo "Falling back to manual deploy"
30+
env:
31+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy Platform to Vercel
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'apps/platform/**'
8+
- 'db/**'
9+
- 'packages/**'
10+
- 'pnpm-lock.yaml'
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: pnpm/action-setup@v3
18+
with: { version: '10.0.0' }
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
cache: 'pnpm'
23+
- run: pnpm install --frozen-lockfile
24+
- run: pnpm db:generate
25+
- name: Trigger Vercel Deployment
26+
run: |
27+
vercel deploy --token ${{ secrets.VERCEL_TOKEN }} --yes --prod
28+
working-directory: apps/platform
29+
env:
30+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
31+
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
32+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
33+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_PLATFORM }}
34+
- name: Run Database Migrations
35+
run: |
36+
npx prisma migrate deploy --schema db/prisma/schema.prisma
37+
env:
38+
DATABASE_URL: ${{ secrets.DATABASE_URL }}

docs/infra/deployment.md

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,35 @@ npm run db:seed
8484

8585
## Step 2: Deploy Marketing Site
8686

87-
### Vercel Dashboard Setup
87+
### Method A: Vercel Dashboard (Recommended for Monorepos)
8888

89-
```bash
90-
# Link project (first time)
91-
vercel link --yes
89+
1. Go to https://vercel.com/new
90+
2. Import `8dazo/captor`
91+
3. **Configure:**
92+
- **Framework Preset**: Next.js
93+
- **Root Directory**: `apps/marketing`
94+
- **Build Command**: `cd ../.. && pnpm install && pnpm db:generate && pnpm --filter marketing build`
95+
- **Output Directory**: `apps/marketing/.next`
96+
- **Install Command**: `cd ../.. && pnpm install`
97+
98+
4. Add Environment Variables:
99+
100+
```
101+
NEXT_PUBLIC_MARKETING_URL=https://captar.ai
102+
```
103+
104+
5. **Deploy**
105+
106+
The `vercel.json` in `apps/marketing/` already has these settings:
92107

93-
# Set root directory
94-
vercel --prod
108+
```json
109+
{
110+
"framework": "nextjs",
111+
"buildCommand": "cd ../.. && pnpm install && pnpm db:generate && pnpm --filter marketing build",
112+
"installCommand": "cd ../.. && pnpm install",
113+
"outputDirectory": "apps/marketing/.next",
114+
"regions": ["iad1"]
115+
}
95116
```
96117

97118
**Project Settings:**
@@ -134,12 +155,44 @@ vercel domains add captar.ai
134155

135156
## Step 3: Deploy Platform App
136157

137-
```bash
138-
# Link as separate project
139-
vercel link --yes
158+
### Method A: Vercel Dashboard (Recommended)
159+
160+
1. Go to https://vercel.com/new
161+
2. Import `8dazo/captor` (same repo, different project)
162+
3. **Configure:**
163+
- **Framework Preset**: Next.js
164+
- **Root Directory**: `apps/platform`
165+
- **Build Command**: `cd ../.. && pnpm install && pnpm db:generate && pnpm --filter @captar/platform build`
166+
- **Output Directory**: `apps/platform/.next`
167+
- **Install Command**: `cd ../.. && pnpm install`
168+
169+
4. **Required Environment Variables:**
170+
171+
| Variable | Description | Example |
172+
| --------------------- | --------------------------------------------------------- | ----------------------- |
173+
| `DATABASE_URL` | PostgreSQL connection | `postgresql://...` |
174+
| `AUTH_SECRET` | NextAuth secret (generate with `openssl rand -base64 32`) | `abc123...` |
175+
| `AUTH_URL` | Your platform URL | `https://api.captar.ai` |
176+
| `AUTH_TRUST_HOST` | Required for Vercel | `true` |
177+
| `CAPTAR_PLATFORM_URL` | Platform URL for SDK | `https://api.captar.ai` |
178+
179+
5. **Deploy**
140180

141-
# Set root directory and deploy
142-
vercel --prod
181+
The `vercel.json` in `apps/platform/` already has these settings:
182+
183+
```json
184+
{
185+
"framework": "nextjs",
186+
"buildCommand": "cd ../.. && pnpm install && pnpm db:generate && pnpm --filter @captar/platform build",
187+
"installCommand": "cd ../.. && pnpm install",
188+
"outputDirectory": "apps/platform/.next",
189+
"regions": ["iad1"],
190+
"functions": {
191+
"app/api/ingest/route.ts": {
192+
"maxDuration": 30
193+
}
194+
}
195+
}
143196
```
144197

145198
**Project Settings:**

0 commit comments

Comments
 (0)