Skip to content

Commit

Permalink
ci: Manual vercel build and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
diego3g committed Mar 2, 2024
1 parent ed8f631 commit 13b011c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ame: Deploy Production

on:
push:
branches:
- 'main'

env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
DIRECT_DATABASE_URL: ${{ secrets.DIRECT_DATABASE_URL }}

jobs:
deploy-production:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
with:
version: 8

- name: Run Prisma Migrate
run: pnpm run db:migrate

- name: Install Vercel CLI
run: pnpm i -g vercel@latest

- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}

- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
7 changes: 5 additions & 2 deletions packages/drizzle/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { neon, neonConfig } from '@neondatabase/serverless'
import { env } from '@nivo/env'
import { drizzle } from 'drizzle-orm/neon-http'
import { migrate } from 'drizzle-orm/neon-http/migrator'

neonConfig.fetchConnectionCache = true

const connection = neon(env.DIRECT_DATABASE_URL)
if (!process.env.DIRECT_DATABASE_URL) {
throw new Error('Invalid environment variable DIRECT_DATABASE_URL')
}

const connection = neon(process.env.DIRECT_DATABASE_URL)
const db = drizzle(connection)

migrate(db, { migrationsFolder: __dirname.concat('/migrations') }).then(() => {
Expand Down

0 comments on commit 13b011c

Please sign in to comment.