diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 0000000..1058b18 --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,45 @@ +name: Deploy Preview + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: [pull_request] + +jobs: + deploy-preview: + permissions: write-all + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Run Prisma Migrate + run: | + touch .env + echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env + + npx prisma generate + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Preview to Vercel + id: deploy + run: echo preview_url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) >> $GITHUB_OUTPUT + + - name: Comment on Pull Request + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + Vercel Preview URL :rocket: : ${{ steps.deploy.outputs.preview_url }} \ No newline at end of file diff --git a/package.json b/package.json index 841df9c..509aeec 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "next build", + "build": "prisma generate && next build", "start": "next start", "lint": "next lint" },