Skip to content

Commit 0280398

Browse files
authored
Merge pull request #389 from underctrl-io/docs-build
feat: add prebuild script for netlify
2 parents be577b9 + 89626f0 commit 0280398

File tree

3 files changed

+63
-531
lines changed

3 files changed

+63
-531
lines changed

apps/website/ignore_build.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const { execSync } = require('child_process');
2+
3+
// Check if there are changes in the website directory
4+
function hasWebsiteChanges() {
5+
try {
6+
// Get the list of changed files in the current commit compared to the base branch
7+
const baseBranch = process.env.BASE_BRANCH || 'main';
8+
const changedFiles = execSync(`git diff --name-only origin/${baseBranch}...HEAD`, { encoding: 'utf8' });
9+
10+
// Check if any of the changed files are in the website directory
11+
const websiteChanges = changedFiles
12+
.split('\n')
13+
.filter(file => file.trim() && file.startsWith('apps/website/'));
14+
15+
return websiteChanges.length > 0;
16+
} catch (error) {
17+
// If we can't determine changes, allow the build to proceed
18+
console.log('Could not determine changes, allowing build to proceed');
19+
return true;
20+
}
21+
}
22+
23+
// Ignore build if:
24+
// 1. Branch is owned by renovate, OR
25+
// 2. No changes in website directory
26+
const shouldIgnore = process.env.BRANCH?.includes('renovate') || !hasWebsiteChanges();
27+
28+
process.exitCode = shouldIgnore ? 0 : 1;
29+
30+
if (shouldIgnore) {
31+
console.log('Build ignored: No relevant changes detected');
32+
} else {
33+
console.log('Build proceeding: Website changes detected');
34+
}

apps/website/netlify.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
ignore = 'node ignore_build.js'

0 commit comments

Comments
 (0)