diff --git a/sites/dev/skip_build.mjs b/sites/dev/skip_build.mjs index 955f3fd79c7..f86092edb91 100755 --- a/sites/dev/skip_build.mjs +++ b/sites/dev/skip_build.mjs @@ -1,4 +1,5 @@ import process from 'node:process' +import { execSync } from 'child_process' // Do not block production builds if (process.env.VERCEL_ENV === 'production') { @@ -12,13 +13,32 @@ if (process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN === 'dependabot[bot]') { process.exit(0) } -// Do not build anything that is not the develop branch -if (process.env.VERCEL_GIT_COMMIT_REF === 'develop') { +const branch = process.env.VERCEL_GIT_COMMIT_REF +// Always build develop branch +if (branch === 'develop') { console.log('✅ - develop build - Proceed to build') process.exit(1) } +// Only build pull requests that made changes to lab +if (process.env.VERCEL_GIT_PULL_REQUEST_ID) { + try { + const changes = execSync( + `git diff --name-only $(git merge-base develop ${branch}) ${branch} sites/shared/ sites/dev` + ).toString() + if (changes) { + console.log('✅ - Lab Pull Request - Proceed to build') + process.exit(1) + } + } catch { + // just don't error out + } + + console.log('🛑 - Pull Request made no changes to Lab - Do not build') + process.exit(0) +} + console.log('🛑 - Unhandled case - Do not build') console.log(` VERCEL_GIT_COMMIT_AUTHOR_LOGIN: ${process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN}`) -console.log(` VERCEL_GIT_COMMIT_REF: ${process.env.VERCEL_GIT_COMMIT_REF}`) +console.log(` VERCEL_GIT_COMMIT_REF: ${branch}`) process.exit(0) diff --git a/sites/lab/skip_build.mjs b/sites/lab/skip_build.mjs index 955f3fd79c7..6c834ce2486 100755 --- a/sites/lab/skip_build.mjs +++ b/sites/lab/skip_build.mjs @@ -1,4 +1,5 @@ import process from 'node:process' +import { execSync } from 'child_process' // Do not block production builds if (process.env.VERCEL_ENV === 'production') { @@ -12,13 +13,32 @@ if (process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN === 'dependabot[bot]') { process.exit(0) } -// Do not build anything that is not the develop branch -if (process.env.VERCEL_GIT_COMMIT_REF === 'develop') { +const branch = process.env.VERCEL_GIT_COMMIT_REF +// Always build develop branch +if (branch === 'develop') { console.log('✅ - develop build - Proceed to build') process.exit(1) } +// Only build pull requests that made changes to lab +if (process.env.VERCEL_GIT_PULL_REQUEST_ID) { + try { + const changes = execSync( + `git diff --name-only $(git merge-base develop ${branch}) ${branch} sites/shared/ sites/lab` + ).toString() + if (changes) { + console.log('✅ - Lab Pull Request - Proceed to build') + process.exit(1) + } + } catch { + // just don't error out + } + + console.log('🛑 - Pull Request made no changes to Lab - Do not build') + process.exit(0) +} + console.log('🛑 - Unhandled case - Do not build') console.log(` VERCEL_GIT_COMMIT_AUTHOR_LOGIN: ${process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN}`) -console.log(` VERCEL_GIT_COMMIT_REF: ${process.env.VERCEL_GIT_COMMIT_REF}`) +console.log(` VERCEL_GIT_COMMIT_REF: ${branch}`) process.exit(0) diff --git a/sites/org/skip_build.mjs b/sites/org/skip_build.mjs index 20f61c1aa61..b9f60f5f938 100755 --- a/sites/org/skip_build.mjs +++ b/sites/org/skip_build.mjs @@ -1,4 +1,5 @@ import process from 'node:process' +import { execSync } from 'child_process' const branches = ['develop', 'joost'] @@ -14,13 +15,32 @@ if (process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN === 'dependabot[bot]') { process.exit(0) } -// Do not build anything that is not the develop branch -if (branches.includes(process.env.VERCEL_GIT_COMMIT_REF)) { - console.log('✅ - elected branch build - Proceed to build') +const branch = process.env.VERCEL_GIT_COMMIT_REF +// Always build develop branch +if (branch === 'develop') { + console.log('✅ - develop build - Proceed to build') process.exit(1) } +// Only build pull requests that made changes to lab +if (process.env.VERCEL_GIT_PULL_REQUEST_ID) { + try { + const changes = execSync( + `git diff --name-only $(git merge-base develop ${branch}) ${branch} sites/shared/ sites/org` + ).toString() + if (changes) { + console.log('✅ - Lab Pull Request - Proceed to build') + process.exit(1) + } + } catch { + // just don't error out + } + + console.log('🛑 - Pull Request made no changes to Lab - Do not build') + process.exit(0) +} + console.log('🛑 - Unhandled case - Do not build') console.log(` VERCEL_GIT_COMMIT_AUTHOR_LOGIN: ${process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN}`) -console.log(` VERCEL_GIT_COMMIT_REF: ${process.env.VERCEL_GIT_COMMIT_REF}`) +console.log(` VERCEL_GIT_COMMIT_REF: ${branch}`) process.exit(0) diff --git a/sites/sanity/skip_build.mjs b/sites/sanity/skip_build.mjs index 0f60675cdf1..17fec486bfb 100755 --- a/sites/sanity/skip_build.mjs +++ b/sites/sanity/skip_build.mjs @@ -15,13 +15,32 @@ if (process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN === 'dependabot[bot]') { process.exit(0) } -// Do not build anything that is not the develop branch -if (process.env.VERCEL_GIT_COMMIT_REF === 'develop') { +const branch = process.env.VERCEL_GIT_COMMIT_REF +// Always build develop branch +if (branch === 'develop') { console.log('✅ - develop build - Proceed to build') process.exit(1) } +// Only build pull requests that made changes to lab +if (process.env.VERCEL_GIT_PULL_REQUEST_ID) { + try { + const changes = execSync( + `git diff --name-only $(git merge-base develop ${branch}) ${branch} sites/sanity` + ).toString() + if (changes) { + console.log('✅ - Lab Pull Request - Proceed to build') + process.exit(1) + } + } catch { + // just don't error out + } + + console.log('🛑 - Pull Request made no changes to Lab - Do not build') + process.exit(0) +} + console.log('🛑 - Unhandled case - Do not build') console.log(` VERCEL_GIT_COMMIT_AUTHOR_LOGIN: ${process.env.VERCEL_GIT_COMMIT_AUTHOR_LOGIN}`) -console.log(` VERCEL_GIT_COMMIT_REF: ${process.env.VERCEL_GIT_COMMIT_REF}`) +console.log(` VERCEL_GIT_COMMIT_REF: ${branch}`) process.exit(0)