How can I ignore a build step based on git information (e.g. branch name) without Vercel cloning the repo? #7373
-
SummaryHi :) To reduce the waiting time for the builds in our monorepo, we're using an ignore build step script to not build a project if it's not needed. However, Vercel still spends about 15 seconds for each project in the monorepo cloning and running the ignore build step script, because the codebase grew in size. We would like to reduce those wait times by not cloning the repo on every check. Because 95% of the time, the cloning would not be necessary since we can check the commit metadata (e.g. branch name) to a environment variable to see if we actually need to build a project. So no code is required (besides the script atm). ExampleNo response Steps to ReproduceOur current script: /* eslint-disable no-console */
const { VERCEL_GIT_COMMIT_REF, BRANCH_PREFIX } = process.env;
console.log(`BRANCH_PREFIX: ${BRANCH_PREFIX}`);
console.log(`VERCEL_GIT_COMMIT_REF: ${VERCEL_GIT_COMMIT_REF}`);
if (
VERCEL_GIT_COMMIT_REF == 'dev' ||
VERCEL_GIT_COMMIT_REF == 'main' ||
VERCEL_GIT_COMMIT_REF.startsWith(`${BRANCH_PREFIX}/`)
) {
// Proceed with the build
console.log('✅ - Build can proceed');
process.exit(1);
}
// Don't build
console.log('🛑 - Build cancelled');
process.exit(0); |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @michaelschufi! Have you checked out Turborepo? I wonder if this is something you can try out in your project. |
Beta Was this translation helpful? Give feedback.
-
This is probably solved by a new Vercel feature. There's a discussion about it in the Vercel Community board. |
Beta Was this translation helpful? Give feedback.
-
This discussion was automatically locked because the community moved to a new site. Please join us at vercel.community |
Beta Was this translation helpful? Give feedback.
This is probably solved by a new Vercel feature.
There's a discussion about it in the Vercel Community board.