Skip to content

Commit 9811531

Browse files
committed
Allow passing a branch in
1 parent ca761ba commit 9811531

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/build/src/extensions/core/vercelSyncEnvVars.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export function syncVercelEnvVars(options?: {
55
projectId?: string;
66
vercelAccessToken?: string;
77
vercelTeamId?: string;
8+
branch?: string;
89
}): BuildExtension {
910
const sync = syncEnvVars(async (ctx) => {
1011
const projectId =
@@ -13,6 +14,17 @@ export function syncVercelEnvVars(options?: {
1314
options?.vercelAccessToken ?? process.env.VERCEL_ACCESS_TOKEN ?? ctx.env.VERCEL_ACCESS_TOKEN;
1415
const vercelTeamId =
1516
options?.vercelTeamId ?? process.env.VERCEL_TEAM_ID ?? ctx.env.VERCEL_TEAM_ID;
17+
const branch =
18+
options?.branch ??
19+
process.env.VERCEL_PREVIEW_BRANCH ??
20+
ctx.env.VERCEL_PREVIEW_BRANCH ??
21+
ctx.branch;
22+
23+
console.debug("syncVercelEnvVars()", {
24+
projectId,
25+
vercelTeamId,
26+
branch,
27+
});
1628

1729
if (!projectId) {
1830
throw new Error(
@@ -42,7 +54,7 @@ export function syncVercelEnvVars(options?: {
4254
}
4355
const params = new URLSearchParams({ decrypt: "true" });
4456
if (vercelTeamId) params.set("teamId", vercelTeamId);
45-
if (ctx.branch) params.set("gitBranch", ctx.branch);
57+
if (branch) params.set("gitBranch", branch);
4658
const vercelApiUrl = `https://api.vercel.com/v8/projects/${projectId}/env?${params}`;
4759

4860
try {

0 commit comments

Comments
 (0)