How to run different build commands base on git branch?
Unanswered
Scottish Fold posted this in #help-forum
Scottish FoldOP
Summary
I have two branches with "main" and "dev", With dev branch I want to build a app for test workers with as build commad as "yarn build", and I will build for custom with "main" branch with "yarn build:prod"
Example
No response
Steps to Reproduce
I have two branches with "main" and "dev", With dev branch I want to build a app for test workers with as build commad as "yarn build", and I will build for custom with "main" branch with "yarn build:prod"
I tried add a "vercel.sh" file at root directory, and its like
#!/bin/bash
if [[ $VERCEL_GIT_COMMIT_REF == "main" ]] ; then
echo "This is our main branch"
yarn build:prod
else
echo "This is not our main branch"
yarn build
fi
and then I overwirte the build command with "bash ./vercel.sh", like this:
image
it runs my build script but caucht an error and has no detail
image
Then I try to find a way from vercel.json configuration file, but I still did not find anything, please teach me what should I do, thanks so much
I have two branches with "main" and "dev", With dev branch I want to build a app for test workers with as build commad as "yarn build", and I will build for custom with "main" branch with "yarn build:prod"
Example
No response
Steps to Reproduce
I have two branches with "main" and "dev", With dev branch I want to build a app for test workers with as build commad as "yarn build", and I will build for custom with "main" branch with "yarn build:prod"
I tried add a "vercel.sh" file at root directory, and its like
#!/bin/bash
if [[ $VERCEL_GIT_COMMIT_REF == "main" ]] ; then
echo "This is our main branch"
yarn build:prod
else
echo "This is not our main branch"
yarn build
fi
and then I overwirte the build command with "bash ./vercel.sh", like this:
image
it runs my build script but caucht an error and has no detail
image
Then I try to find a way from vercel.json configuration file, but I still did not find anything, please teach me what should I do, thanks so much
2 Replies
Scottish FoldOP