Skip to content

chore: update versions for release (canary) #111

chore: update versions for release (canary)

chore: update versions for release (canary) #111

Workflow file for this run

name: Vercel Deployments
on:
push:
branches:
- main
- canary
paths:
- ".github/workflows/deploy.yml"
- "apps/**"
- "packages/**"
pull_request:
branches:
- main
- canary
types:
- opened
- synchronize
- reopened
paths:
- ".github/workflows/deploy.yml"
- "apps/**"
- "packages/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read # to check out code
issues: write # to create comments on PRs
pull-requests: write # to create comments on PRs
deployments: write # to create and update deployment statuses
jobs:
deploy:
name: Deploy to Vercel
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup CI Environment
uses: ./.github/actions/setup-environment
- name: Install and Configure Vercel CLI
run: pnpm add -g vercel@latest
# Create a deployment record for GitHub
- name: Create GitHub Deployment
id: deployment
uses: actions/github-script@v7
with:
script: |
const { data: deployment } = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.sha,
environment: github.ref == 'refs/heads/main' ? 'Production' : 'Preview',
auto_merge: false,
required_contexts: [],
description: 'Preparing deployment to Vercel!'
});
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deployment.id,
state: 'in_progress',
description: 'Deployment in progress! Building your awesome app...'
});
return { id: deployment.id };
- name: Deploy Production to Vercel
if: github.ref == 'refs/heads/main'
id: deploy-production
run: |
DEPLOY_URL=$(vercel deploy --archive=tgz --token=${{ secrets.VERCEL_TOKEN }} --prod)
echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Deploy Preview to Vercel
if: github.ref != 'refs/heads/main'
id: deploy-preview
run: |
DEPLOY_URL=$(vercel deploy --archive=tgz --token=${{ secrets.VERCEL_TOKEN }})
echo "Preview URL: $DEPLOY_URL"
echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# Update deployment status to success
- name: Update Deployment Status (Success)
if: success()
uses: actions/github-script@v7
with:
script: |
const deploymentId = ${{ steps.deployment.outputs.result }}.id;
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deploymentId,
state: 'success',
environment_url: process.env.DEPLOY_URL,
log_url: process.env.DEPLOY_URL,
description: 'Woohoo! Deployment completed successfully! Your app is ready!'
});
# Update deployment status to failure
- name: Update Deployment Status (Failure)
if: failure()
uses: actions/github-script@v7
with:
script: |
const deploymentId = ${{ steps.deployment.outputs.result }}.id;
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deploymentId,
state: 'failure',
description: 'We hit a small bump! Let\'s fix this together and try again!'
});
- name: Post Deployment Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
github.rest.issues.createComment({
owner,
repo,
issue_number,
body: `## 🎉 Great news! Preview deployment is ready!\n\n🔍 **Preview URL:** ${process.env.DEPLOY_URL}\n\n🚀 Check out your awesome changes in action!`
});