forked from lobehub/lobehub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvercelIgnoredBuildStep.js
More file actions
41 lines (34 loc) · 1006 Bytes
/
vercelIgnoredBuildStep.js
File metadata and controls
41 lines (34 loc) · 1006 Bytes
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
41
const { execSync } = require('node:child_process');
// 获取当前分支名
const branchName = process.env.VERCEL_GIT_COMMIT_REF || '';
function shouldProceedBuild() {
// 如果是 lighthouse 分支或以 testgru 开头的分支,取消构建
if (branchName === 'lighthouse' || branchName.startsWith('gru/')) {
return false;
}
try {
// 检查文件变更,排除特定文件和目录
const diffCommand =
'git diff HEAD^ HEAD --quiet -- \
":!./*.md" \
":!./Dockerfile" \
":!./.github" \
":!./.husky" \
":!./scripts"';
execSync(diffCommand);
return false;
} catch {
return true;
}
}
const shouldBuild = shouldProceedBuild();
console.log('shouldBuild:', shouldBuild);
if (shouldBuild) {
console.log('✅ - Build can proceed');
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
} else {
console.log('🛑 - Build cancelled');
// eslint-disable-next-line unicorn/no-process-exit
process.exit(0);
}