You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allowing to override baseBranch via environment variables or as CLI flags could be beneficial for various edge cases.
One example is a Next.js app deployed on Vercel with two branches assigned to different domains and environment variables (e.g. example.com for main, and dev.example.com for dev). If baseBranch is set to origin/main and remote caching is enabled, dev branch builds will use the main branch artifacts/caches, which it should not.
The hacky solution that I can think of is to rewrite the baseBranch property on package.json before Turborepo runs:
// update-branch.jsconstfs=require("fs");constpath=require("path");constpackageJson=require("../package.json");packageJson.turbo.baseBranch=process.env.VERCEL_GIT_COMMIT_REF||process.env.TURBO_BASE_BRANCH||"origin/main";fs.writeFileSync(path.join(__dirname,"../package.json"),`${JSON.stringify(packageJson,null,2)}\n`);// then run node update-branch && yarn turbo run build
If theoretically using an environment variable or as a CLI flag is possible, it might look something like this:
# using cli flag
turbo run build --baseBranch="origin/dev"# using environment variable
TURBO_BASE_BRANCH="origin/dev" turbo run build
I think it could be more than this, but as for the example use case it does fit and currently being deployed on production (and dev). What do y'all think? 😄
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Allowing to override
baseBranch
via environment variables or as CLI flags could be beneficial for various edge cases.One example is a Next.js app deployed on Vercel with two branches assigned to different domains and environment variables (e.g.
example.com
for main, anddev.example.com
for dev). IfbaseBranch
is set toorigin/main
and remote caching is enabled,dev
branch builds will use themain
branch artifacts/caches, which it should not.I may misunderstood how
baseBranch
works on the documentation, but from my understanding "it defaults to the main branch" which I don't know if it automatically assumesorigin/main
or resolving the current project git branch.The hacky solution that I can think of is to rewrite the
baseBranch
property onpackage.json
before Turborepo runs:If theoretically using an environment variable or as a CLI flag is possible, it might look something like this:
I think it could be more than this, but as for the example use case it does fit and currently being deployed on production (and dev). What do y'all think? 😄
Beta Was this translation helpful? Give feedback.
All reactions