vercel-action icon indicating copy to clipboard operation
vercel-action copied to clipboard

[Feature] Exclude Specific Branches from Preview Deployments

Open iamfj opened this issue 1 year ago • 0 comments

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-branches input.

  • 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

  1. 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".
  2. Setup Script Changes:

    Modified the scripts/setup.mjs to accept the -b argument, enabling easy specification of branches to be ignored. The script dynamically constructs the command for the Ignored Build Step based on the IGNORED_BRANCHES and IGNORED_BUILD_COMMAND environment 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.

iamfj avatar Mar 26 '24 19:03 iamfj