Skip to content

Commit

Permalink
Add vercel deploy in github actions (#75)
Browse files Browse the repository at this point in the history
* Add vercel deploy in github actions

* Fix actions

* Use vercel cwd flag

* Exec with global cli

* Remove cwd for build step

* Revert remove cwd from build

* Rename production job

* Revert useless vercel scripts

* Remove cwd notion

* Add binaryTargets to prisma

* Remove vercel from turbo pipeline

* Use generic workflow

* Set env in generic workflow
  • Loading branch information
foyarash authored Nov 29, 2023
1 parent 8381d1a commit 561f37a
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
59 changes: 59 additions & 0 deletions .github/workflows/vercel-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Vercel deploy
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}

on:
workflow_call:
inputs:
environment:
required: true
type: string
extra_args:
required: false
type: string

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

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Dependencies
run: yarn install

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Pull Vercel Environment Information (Docs)
run: vercel pull --yes --environment=${{ inputs.environment }} --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_DOCS }}
- name: Build Project Artifacts (Docs)
run: vercel build ${{ inputs.extra_args }} --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_DOCS }}
- name: Deploy Project Artifacts to Vercel (Docs)
run: vercel deploy ${{ inputs.extra_args }} --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_DOCS }}

- name: Intermediate cleanup
run: rm -rf .vercel

- name: Pull Vercel Environment Information (Example)
run: vercel pull --yes --environment=${{ inputs.environment }} --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_EXAMPLE }}
- name: Build Project Artifacts (Example)
run: vercel build ${{ inputs.extra_args }} --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_EXAMPLE }}
- name: Deploy Project Artifacts to Vercel (Example)
run: vercel deploy ${{ inputs.extra_args }} --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_EXAMPLE }}
12 changes: 12 additions & 0 deletions .github/workflows/vercel-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Vercel Preview Deployment

on:
push:
branches-ignore:
- main
jobs:
Deploy-Preview:
uses: ./.github/workflows/vercel-deploy.yml
secrets: inherit
with:
environment: preview
16 changes: 16 additions & 0 deletions .github/workflows/vercel-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Vercel Production Deployment

on:
pull_request:
types:
- closed
branches:
- "main"
jobs:
Deploy-Production:
if: startsWith(github.head_ref, 'changeset-release/') && github.event.pull_request.merged == true
uses: ./.github/workflows/vercel-deploy.yml
secrets: inherit
with:
environment: production
extra_args: --prod
3 changes: 2 additions & 1 deletion apps/example/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}

generator jsonSchema {
Expand Down

0 comments on commit 561f37a

Please sign in to comment.