iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
😊
Limit Vercel Preview Deployments to Specific Branch Prefixes
When pushing to a repository linked with Vercel, a preview deployment is performed every time.
However, I would like to reduce the number of deployments for the following reasons:
- Concern about hitting the deployment limits of a free account.
- I only want it to deploy at the specific timing when I want to preview.
Conclusion
This is a slight modification of what has been mentioned in articles by authors like catnose.
I have changed the check in the if clause to a condition that determines whether it contains a specific prefix.
shell/vercel/ignore-build.hs
#!/bin/bash
echo "VERCEL_GIT_COMMIT_REF: $VERCEL_GIT_COMMIT_REF"
if [[ "`echo $VERCEL_GIT_COMMIT_REF | grep 'develop/*'`" ]]; then
# Proceed with the build
echo "✅ - Build can proceed"
exit 1;
else
# Don't build
echo "🛑 - Build cancelled"
exit 0;
fi
References
Ignoring branches other than specific ones in Vercel preview deployments
Using Vercel's Ignored Build Step to create preview builds only when specific branches are pushed
Discussion