-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathignore-vercel-build.js
40 lines (37 loc) · 1.33 KB
/
ignore-vercel-build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { execSync } from "child_process";
const branchName =
process.env.VERCEL_GIT_COMMIT_REF ||
execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
const currentAppName = process.env.APP_NAME;
const homepageAppName = "jazz-homepage";
if (
branchName === "main" &&
process.env.VERCEL_GIT_COMMIT_MESSAGE?.includes("docs")
) {
// If merging a "docs" branch into "main" (commit message contains "docs"), skip all apps except "homepage"
if (currentAppName === homepageAppName) {
console.log(
`✅ Building homepage because a "docs" branch was merged into "main".`,
);
process.exit(1); // Continue with the build
} else {
console.log(
`🛑 Skipping build for ${currentAppName} after "docs" branch merged to main.`,
);
process.exit(0); // Skip the build
}
} else if (branchName.includes("docs")) {
// If on a "docs" branch, skip all apps except "homepage"
if (currentAppName === homepageAppName) {
console.log(`✅ Building homepage for "docs" branch.`);
process.exit(1); // Continue with the build
} else {
console.log(`🛑 Skipping build for ${currentAppName} on "docs" branch.`);
process.exit(0); // Skip the build
}
}
// Default behavior: build everything.
console.log(
`✅ Proceeding with build for ${currentAppName} on branch ${branchName}.`,
);
process.exit(1);