-
Notifications
You must be signed in to change notification settings - Fork 4
/
skip-smartling-build.cjs
49 lines (39 loc) · 1.1 KB
/
skip-smartling-build.cjs
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
42
43
44
45
46
47
48
49
#!/usr/bin/env node
const { execSync } = require('child_process');
function getGitCommitRef() {
return process.env.VERCEL_GIT_COMMIT_REF;
}
function getCommitAuthor() {
return execSync('git show -s --format="%an <%ae>"', { encoding: 'utf8' }).trim();
}
function checkForChanges() {
try {
execSync('git diff HEAD^ HEAD --quiet');
return false;
} catch {
return true;
}
}
function main() {
const vercelGitCommitRef = getGitCommitRef();
console.log(`VERCEL_GIT_COMMIT_REF: ${vercelGitCommitRef}`);
const author = getCommitAuthor();
console.log(`Commit author: ${author}`);
if (vercelGitCommitRef === "main") {
console.log("Branch is main. Building site.");
process.exit(1);
}
console.log("Checking for changes");
if (!checkForChanges()) {
console.log("No changes found. Skipping build.");
process.exit(0);
}
if (author === "adjust-pc-team <[email protected]>") {
console.log("Skipping build from Smartling pending fixes");
process.exit(0);
} else {
console.log("Building site");
process.exit(1);
}
}
main();