[Feature] Exclude Specific Branches from Preview Deployments
This pull request introduces a new feature to the snaplet/vercel-action GitHub Action, allowing users to specify branches that should be excluded from Vercel preview deployments. This enhancement is particularly useful in development workflows like GitFlow, where certain branches (e.g., main, develop) are considered as production (or staging) and should not have associated preview deployments.
Features
-
Ignore Branches: Users can now define a list of branches that the Vercel GitHub Action should ignore when triggering preview deployments. This is controlled by the new
ignored-branchesinput. -
Custom Ignore Build Command: Provides the capability to set a custom command for the Ignored Build Step in project settings, ensuring flexibility in handling ignored branches.
Implementation Details
-
GitHub Action Input:
Added new inputs to the GitHub Action:
ignored-branches: Specifies the branches to be excluded from preview deployments. Defaults to "main,master,develop".
-
Setup Script Changes:
Modified the
scripts/setup.mjsto accept the-bargument, enabling easy specification of branches to be ignored. The script dynamically constructs the command for the Ignored Build Step based on theIGNORED_BRANCHESandIGNORED_BUILD_COMMANDenvironment variables.
Motivation
In workflows like GitFlow, the develop and main branches are often considered as production. However, Vercel currently supports only one production deployment at a time. This feature allows teams to bypass preview deployments for specific branches, aligning better with their development practices without cluttering the deployment environment.
Usage
Users can specify the branches to ignore in the GitHub Action configuration like so:
ignored-branches:
description: Branches to ignore for preview deployments. Defaults to "main,master,develop".
required: false
default: main,master,develop
By setting the ignored-branches input, teams can customize which branches should bypass the preview deployment process, adding flexibility to their continuous deployment workflows.