Skip to content

Deploy Production

Deploy Production #72

Workflow file for this run

name: Deploy Production
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
workflow_dispatch:
inputs:
confirm:
description: 'Type "deploy" to confirm production deployment'
required: true
type: string
concurrency:
group: deploy-production
cancel-in-progress: false
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }}
jobs:
validate:
name: Validate
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ steps.check.outputs.should_deploy }}
ref: ${{ steps.check.outputs.ref }}
steps:
- name: Check deployment conditions
id: check
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ "${{ github.event.inputs.confirm }}" != "deploy" ]; then
echo "❌ Deployment cancelled. You must type 'deploy' to confirm."
exit 1
fi
echo "should_deploy=true" >> $GITHUB_OUTPUT
echo "ref=${{ github.ref }}" >> $GITHUB_OUTPUT
else
# workflow_run event
if [ "${{ github.event.workflow_run.conclusion }}" = "success" ]; then
echo "should_deploy=true" >> $GITHUB_OUTPUT
echo "ref=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_OUTPUT
else
echo "❌ CI failed, skipping deployment"
echo "should_deploy=false" >> $GITHUB_OUTPUT
fi
fi
deploy-production:
name: Deploy to Vercel Production
needs: validate
if: needs.validate.outputs.should_deploy == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
environment:
name: production
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.validate.outputs.ref }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Install Vercel CLI
run: pnpm add -g vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Workspace Packages
run: pnpm build
env:
DEPLOYMENT_MODE: saas
NEXT_PUBLIC_DEPLOYMENT_MODE: saas
BETTER_AUTH_SECRET: ${{ secrets.BETTER_AUTH_SECRET }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy to Vercel Production
id: deploy
run: |
URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }})
echo "url=$URL" >> $GITHUB_OUTPUT
echo "🚀 Deployed to production: $URL"
- name: Create GitHub Deployment Status
uses: actions/github-script@v7
with:
script: |
const url = '${{ steps.deploy.outputs.url }}';
console.log(`✅ Production deployment successful: ${url}`);