Skip to content

Commit

Permalink
feat: setup deployment using vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
ianriizky committed Jul 23, 2024
1 parent 38cd4b9 commit 5fc996e
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
NODE_ENV=development

DB_URL=postgresql://root@localhost:5432/push_notification_nextjs_firebase
DB_URL_NON_POOLING= # optional

FIREBASE_ADMIN_TYPE=
FIREBASE_ADMIN_PROJECT_ID=
Expand Down
133 changes: 133 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# https://dev.to/chuddyjoachim/nextjs-ci-cd-on-vercel-with-github-actions-7g7
name: Deploy to Vercel

on:
push:
branches:
- "main"

jobs:
vercel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: dkershner6/vercel-set-env-action@v3.0.3
with:
token: ${{ secrets.VERCEL_TOKEN }}
teamId: ${{ secrets.VERCEL_TEAM_ID }} # optional, without will use personal
projectName: push-notification-nextjs-firebase # project name in Vercel
envVariableKeys: >-
DB_URL,
DB_URL_NON_POOLING,
FIREBASE_ADMIN_TYPE,
FIREBASE_ADMIN_PROJECT_ID,
FIREBASE_ADMIN_PRIVATE_KEY_ID,
FIREBASE_ADMIN_PRIVATE_KEY,
FIREBASE_ADMIN_CLIENT_EMAIL,
FIREBASE_ADMIN_CLIENT_ID,
FIREBASE_ADMIN_AUTH_URI,
FIREBASE_ADMIN_TOKEN_URI,
FIREBASE_ADMIN_AUTH_PROVIDER_X509_CERT_URL,
FIREBASE_ADMIN_CLIENT_X509_CERT_URL,
FIREBASE_ADMIN_UNIVERSE_DOMAIN,
NEXT_PUBLIC_FIREBASE_API_KEY,
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
NEXT_PUBLIC_FIREBASE_PROJECT_ID,
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
NEXT_PUBLIC_FIREBASE_APP_ID,
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
NEXT_PUBLIC_FIREBASE_FCM_VAPID_KEY
env:
DB_URL: ${{ secrets.DB_URL }}
TARGET_DB_URL: preview,development,production # comma delimited, one of [production, preview, development]
TYPE_DB_URL: encrypted # one of [plain, encrypted]

DB_URL_NON_POOLING: ${{ secrets.DB_URL_NON_POOLING }}
TARGET_DB_URL_NON_POOLING: preview,development,production
TYPE_DB_URL_NON_POOLING: encrypted

FIREBASE_ADMIN_TYPE: ${{ secrets.FIREBASE_ADMIN_TYPE }}
TARGET_FIREBASE_ADMIN_TYPE: preview,development,production
TYPE_FIREBASE_ADMIN_TYPE: encrypted

FIREBASE_ADMIN_PROJECT_ID: ${{ secrets.FIREBASE_ADMIN_PROJECT_ID }}
TARGET_FIREBASE_ADMIN_PROJECT_ID: preview,development,production
TYPE_FIREBASE_ADMIN_PROJECT_ID: encrypted

FIREBASE_ADMIN_PRIVATE_KEY_ID: ${{ secrets.FIREBASE_ADMIN_PRIVATE_KEY_ID }}
TARGET_FIREBASE_ADMIN_PRIVATE_KEY_ID: preview,development,production
TYPE_FIREBASE_ADMIN_PRIVATE_KEY_ID: encrypted

FIREBASE_ADMIN_PRIVATE_KEY: ${{ secrets.FIREBASE_ADMIN_PRIVATE_KEY }}
TARGET_FIREBASE_ADMIN_PRIVATE_KEY: preview,development,production
TYPE_FIREBASE_ADMIN_PRIVATE_KEY: encrypted

FIREBASE_ADMIN_CLIENT_EMAIL: ${{ secrets.FIREBASE_ADMIN_CLIENT_EMAIL }}
TARGET_FIREBASE_ADMIN_CLIENT_EMAIL: preview,development,production
TYPE_FIREBASE_ADMIN_CLIENT_EMAIL: encrypted

FIREBASE_ADMIN_CLIENT_ID: ${{ secrets.FIREBASE_ADMIN_CLIENT_ID }}
TARGET_FIREBASE_ADMIN_CLIENT_ID: preview,development,production
TYPE_FIREBASE_ADMIN_CLIENT_ID: encrypted

FIREBASE_ADMIN_AUTH_URI: ${{ secrets.FIREBASE_ADMIN_AUTH_URI }}
TARGET_FIREBASE_ADMIN_AUTH_URI: preview,development,production
TYPE_FIREBASE_ADMIN_AUTH_URI: encrypted

FIREBASE_ADMIN_TOKEN_URI: ${{ secrets.FIREBASE_ADMIN_TOKEN_URI }}
TARGET_FIREBASE_ADMIN_TOKEN_URI: preview,development,production
TYPE_FIREBASE_ADMIN_TOKEN_URI: encrypted

FIREBASE_ADMIN_AUTH_PROVIDER_X509_CERT_URL: ${{ secrets.FIREBASE_ADMIN_AUTH_PROVIDER_X509_CERT_URL }}
TARGET_FIREBASE_ADMIN_AUTH_PROVIDER_X509_CERT_URL: preview,development,production
TYPE_FIREBASE_ADMIN_AUTH_PROVIDER_X509_CERT_URL: encrypted

FIREBASE_ADMIN_CLIENT_X509_CERT_URL: ${{ secrets.FIREBASE_ADMIN_CLIENT_X509_CERT_URL }}
TARGET_FIREBASE_ADMIN_CLIENT_X509_CERT_URL: preview,development,production
TYPE_FIREBASE_ADMIN_CLIENT_X509_CERT_URL: encrypted

FIREBASE_ADMIN_UNIVERSE_DOMAIN: ${{ secrets.FIREBASE_ADMIN_UNIVERSE_DOMAIN }}
TARGET_FIREBASE_ADMIN_UNIVERSE_DOMAIN: preview,development,production
TYPE_FIREBASE_ADMIN_UNIVERSE_DOMAIN: encrypted

NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
TARGET_NEXT_PUBLIC_FIREBASE_API_KEY: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_API_KEY: encrypted

NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
TARGET_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: encrypted

NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}
TARGET_NEXT_PUBLIC_FIREBASE_PROJECT_ID: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_PROJECT_ID: encrypted

NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}
TARGET_NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: encrypted

NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}
TARGET_NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: encrypted

NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}
TARGET_NEXT_PUBLIC_FIREBASE_APP_ID: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_APP_ID: encrypted

NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
TARGET_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: encrypted

NEXT_PUBLIC_FIREBASE_FCM_VAPID_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_FCM_VAPID_KEY }}
TARGET_NEXT_PUBLIC_FIREBASE_FCM_VAPID_KEY: preview,development,production
TYPE_NEXT_PUBLIC_FIREBASE_FCM_VAPID_KEY: encrypted

- uses: amondnet/vercel-action@v25.2.0
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
github-token: ${{ secrets.GITHUB_TOKEN }} # Optional
vercel-args: "--prod" # Optional
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} # Required
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}} # Required
5 changes: 3 additions & 2 deletions src/database/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ generator client {
}

datasource db {
provider = "postgresql"
url = env("DB_URL")
provider = "postgresql"
url = env("DB_URL")
directUrl = env("DB_URL_NON_POOLING")
}

model Subscription {
Expand Down
6 changes: 6 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": 2,
"github": {
"enabled": false
}
}

0 comments on commit 5fc996e

Please sign in to comment.