Skip to content

Commit ca761ba

Browse files
committed
Detect the branch from Vercel env var (set during build)
1 parent d661d71 commit ca761ba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/core/src/v3/apiClient/getBranch.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ export function getBranch({
1212
return specified;
1313
}
1414

15-
// not specified, so detect from process.env
15+
// not specified, so detect our variable from process.env
1616
const envVar = getEnvVar("TRIGGER_PREVIEW_BRANCH");
1717
if (envVar) {
1818
return envVar;
1919
}
2020

21+
// detect the Vercel preview branch
22+
const vercelPreviewBranch = getEnvVar("VERCEL_GIT_COMMIT_REF");
23+
if (vercelPreviewBranch) {
24+
return vercelPreviewBranch;
25+
}
26+
2127
// not specified, so detect from git metadata
2228
if (gitMeta?.commitRef) {
2329
return gitMeta.commitRef;

0 commit comments

Comments
 (0)