An Azure DevOps Extension for deploying to Vercel from Azure Pipelines
MIT License
This extension contains Azure Pipelines tasks for automatically deploying your Azure DevOps project to Vercel.
Note: This step will not work until the extension is shared with the user or we make the extension public.
vercel-deployment-task
and vercel-azdo-pr-comment-task
.
Note: Within a pipeline definition, the tasks will be used like
- task: vercel-deployment-task@1
. The@1
represents the Major version of the task that the pipeline should use. Make sure to indicate the latest major version of the task when creating your pipeline.
Explore the following pipeline guides for further set up instructions:
This short guide will demonstrate how the extension can be used to automatically deploy the main
branch to production. Make sure the steps in Extension Set Up have been completed.
Start by creating a new pipeline file in your repo called basic-pipeline.yml
. Either use the in-browser editor, or in your local file editor.
Add a trigger:
, pool:
, and steps:
declarations:
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
# - task: ...
The
trigger:
declaration states that this pipeline should run for all commits to themain
branch.
Now add the extension's task vercel-deployment-task
:
steps:
- task: vercel-deployment-task@1
name: Deploy
inputs:
vercelProjectId: "<project-id>"
vercelOrgId: "<org-id>"
vercelToken: "<vercel-token>" # '$(VERCEL_TOKEN)'
production: true
vercelToken
should reference the secret variable defined in Extension Set Up.Commit, and push the pipeline to the repository.
Navigate to Azure Pipelines and run the task for the first time if it doesn't run automatically.
Make a change to your project and commit to the main
branch, a new deployment pipeline run should automatically kick off in Azure Pipelines, and the Vercel Project should automatically update.
This guide will demonstrate how to improve the Basic Pipeline Set Up pipeline in order to deploy from main
to production and deploy from pull requests to preview.
steps
block
variables:
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
production: true
input to be production: $(isMain)
inputs:
, add a condition
:
inputs:
# ...
condition: or(eq(variables.isMain, true), eq(variables['Build.Reason'], 'PullRequest'))
vercel-deployment-task
step, adding the PR commenting feature:
- task: vercel-azdo-pr-comment-task@1
inputs:
azureToken: $(AZURE_PAT)
deploymentTaskMessage: $(Deploy.deploymentTaskMessage)
vercel-deployment-task
sets an output variable called deploymentTaskMessage
. The reference $(Deploy.deploymentTaskMessage)
comes from the name: Deploy
on the vercel-deployment-task
step.main
branch.main
. A new pipeline execution should trigger and it should create a preview deployment on Vercel as well as comment back on the PR with the preview URL.vercel-deployment-task
An Azure Pipelines Task Extension for automatically deploying to Vercel.
The configuration inputs vercelProjectID
, vercelOrgID
, and vercelToken
can all be replaced with environment variables. See their respective property sections for more details.
vercelProjectId
The ID of your Vercel Project.
Can alternatively be set as the environment variable VERCEL_PROJECT_ID
.
Type: string
Required: false
vercelOrgId
The ID of your Vercel Org.
Can alternatively be set as the environment variable VERCEL_ORG_ID
.
Type: string
Required: false
vercelToken
A Vercel personal access token with deploy permissions for your Vercel Project. Guide
Can alternatively be set as the environment variable VERCEL_TOKEN
.
Type: string
Required: false
vercelCwd
The Current Working Directory option can be used to provide a working directory (that can be different from the current directory) when running Vercel deployment task.
This option can be a relative or absolute path. Guide
Can alternatively be set as the environment variable VERCEL_CWD
.
Type: string
Required: false
production
Should the task deploy to production? When omitted, or set to false
, the task will create preview deployments.
Type: boolean
Default: false
Required: false
debug
Enable --debug
output for the internal Vercel CLI operations.
Type: boolean
Default: false
Required: false
archive
Enable --archive=tgz
flag for the internal Vercel CLI operations.
Type: boolean
Default: false
Required: false
env
Adding enviroment variables at runtime utilizing Vercel CLI's --env
option.
Type: string
Required: false
buildEnv
Adding build enviroment variables to the build step utilizing Vercel CLI's --build-env
option.
Type: string
Required: false
logs
Enable --logs
flag for the internal Vercel CLI operations.
Type: boolean
Default: false
Required: false
deploymentURL
The URL of the deployment.
Type: string
originalDeploymentURL
Original URL of the deployment. Can be used to create your own alias in a depending separate task.
Type: string
deploymentTaskMessage
The output from the deployment. Can be passed to Vercel Azure DevOps Pull Request Comment Task.
Type: string
vercel-azdo-pr-comment-task
azureToken
An Azure personal access token with the Git 'PullRequestContribute' permission for your Azure DevOps Organization. Guide
Type: string
Required: true
deploymentTaskMessage
The message to be commented on the Pull Request. Generally is created by the Vercel Deployment Task.
Type: string
Required: true
Repositories
optionmain
branch+
button to create a new validation policy.Keep the policy marked as Required so that commits directly to
main
are prevented.
main
branch, and if everything is set up correctly, the pipeline will run and comment back on the PR the deployment URL 🎉