Skip to content

Instantly share code, notes, and snippets.

@israelias
Created January 8, 2025 10:16
Show Gist options
  • Save israelias/4f8ccd0996add353d6905bbdce658446 to your computer and use it in GitHub Desktop.
Save israelias/4f8ccd0996add353d6905bbdce658446 to your computer and use it in GitHub Desktop.
Ignored Build Step Configuration for Vercel for Github

To configure Vercel to skip deployments when changes are made solely to the .github/ directory, the docs/ directory, or any Markdown (*.md) files, you can set up the Ignored Build Step in your Vercel project settings. This ensures that modifications to these specific files or directories do not trigger unnecessary deployments.

Steps to Configure the Ignored Build Step:

  1. Access Vercel Project Settings:

    • Navigate to your project on the Vercel dashboard.
    • Click on the Settings tab.
    • Select the Git section.
  2. Set Up the Ignored Build Step:

    • In the Ignored Build Step section, you can specify a command that determines whether a build should proceed based on the changes in your commits.

    • To skip builds when only files in the .github/ and docs/ directories or any Markdown files are modified, use the following command:

      # Check for changes outside the .github/ and docs/ directories and Markdown files
      if git diff --quiet HEAD^ HEAD -- .github/ docs/ '*.md'; then
        echo "Only .github/, docs/, or Markdown files changed; skipping build."
        exit 0
      else
        echo "Relevant changes detected; proceeding with build."
        exit 1
      fi

    How:

    • git diff --quiet HEAD^ HEAD -- .github/ docs/ '*.md': This command checks if the differences between the latest commit and its parent are confined to the .github/ and docs/ directories or any files matching the *.md pattern.
    • If only these specified files or directories have changed, the script exits with status 0, signaling Vercel to skip the build.
    • If other files have changed, it exits with status 1, allowing the build to proceed.
  3. Save:

    • After entering the command, save your settings.
    • Vercel will now execute this script for each commit to determine whether a build should be initiated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment