Use vercel project ID for ignore build step

This commit is contained in:
Anselm
2025-06-06 14:02:51 +01:00
parent 854c6761a4
commit d982bb50db

View File

@@ -3,38 +3,38 @@ 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";
const currentProjectID = process.env.VERCEL_PROJECT_ID;
const homepageProjectID = "prj_NPOqHYn0F78DVcEmSiTf0wgNcqL8";
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) {
if (currentProjectID === homepageProjectID) {
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.`,
`🛑 Skipping build for ${currentProjectID} 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) {
if (currentProjectID === homepageProjectID) {
console.log(`✅ Building homepage for "docs" branch.`);
process.exit(1); // Continue with the build
} else {
console.log(`🛑 Skipping build for ${currentAppName} on "docs" branch.`);
console.log(`🛑 Skipping build for ${currentProjectID} on "docs" branch.`);
process.exit(0); // Skip the build
}
}
// Default behavior: build everything.
console.log(
`✅ Proceeding with build for ${currentAppName} on branch ${branchName}.`,
`✅ Proceeding with build for ${currentProjectID} on branch ${branchName}.`,
);
process.exit(1);