Skip to content

Commit

Permalink
Add Vercel deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mnixry committed Feb 6, 2024
1 parent c448dbb commit 337a753
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -47,3 +46,63 @@ jobs:
with:
name: dists
path: ${{ steps.find-dists.outputs.dirs }}

deploy:
runs-on: ubuntu-latest
needs: build

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
DEPLOY_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }}

steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: dists

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

- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

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

- name: Pull Vercel Environment Information
run: |
vercel pull \
--yes \
--environment=${{ env.DEPLOY_ENV }} \
--token=${{ env.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: |
if [ "${{ env.DEPLOY_ENV }}" == "production" ]; then
vercel build \
--prod \
--token=${{ env.VERCEL_TOKEN }}
else
vercel build \
--token=${{ env.VERCEL_TOKEN }}
fi
- name: Deploy Project Artifacts to Vercel
run: |
if [ "${{ env.DEPLOY_ENV }}" == "production" ]; then
vercel deploy \
--prebuilt \
--prod \
--token=${{ env.VERCEL_TOKEN }}
else
vercel deploy \
--prebuilt \
--token=${{ env.VERCEL_TOKEN }}
fi

0 comments on commit 337a753

Please sign in to comment.