Home
Support Forums

Build netlify only if base dir changes

I want to build netlify only if content inside base changes

Pasting the netlify.toml below

[build]
  base = "wiki/"
  command = "./scripts/build.sh"
  publish = "./public"
  ignore = "git diff --quiet HEAD^ HEAD"

[context.production.environment]
  HUGO_VERSION = "0.74.3"
  LOOP = "false"

[context.deploy-preview.environment]
  HUGO_VERSION = "0.74.3"
  LOOP = "false"

Somehow it’s still create a build

Editing previous reply as it seems like your TOML should work, just make sure that you have
[build] at the top like so:

[build]
  base = "wiki/"
  command = "./scripts/build.sh"
  publish = "./public"
  ignore = "git diff --quiet HEAD^ HEAD"

[context.production.environment]
  HUGO_VERSION = "0.74.3"
  LOOP = "false"

[context.deploy-preview.environment]
  HUGO_VERSION = "0.74.3"
  LOOP = "false"

Also, just to confirm the site was created or re-linked since october 2019 - https://docs.netlify.com/configure-builds/file-based-configuration/#ignore-builds

@AaronP Site was created few weeks back

Also, somehow i missed [build] to paste here, but i have the build in toml, but it still creates a build

Some more details below

  • Master branch has the above changes, now i create a new branch from master and make changes outside wiki folder and create a PR, Netlify still creates a build

Hi, @mbj36. It is hard to say for sure what is happening without some more information. Would you please send us the deploy id for a deploy where the build.ignore command isn’t working as expected?

Our support team will be happy to research this once we have an example deploy to examine.

@luke Here are the details

Are you able to post the exact deploy that you attempted? Once youre on the site view you can click deploys at the top and then the specific deploy :slight_smile:

Okay here are the details

This commit which spinned a deployed shouldn;'t have happened there is no change in wiki folder

Logs -

8:13:07 PM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41
8:13:07 PM: build-image tag: v3.5.0
8:13:07 PM: buildbot version: 1ba1edc027724f9c3e0906641d7cd0b5223a3593
8:13:07 PM: Fetching cached dependencies
8:13:07 PM: Starting to download cache of 555.0MB
8:13:18 PM: Finished downloading cache in 10.246660361s
8:13:18 PM: Starting to extract cache
8:13:26 PM: Finished extracting cache in 8.844267351s
8:13:27 PM: Finished fetching cache in 19.377573232s
8:13:27 PM: Starting to prepare the repo for build
8:13:27 PM: Preparing Git Reference pull/7083/head
8:13:30 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'wiki' versus '' in the Netlify UI
8:13:30 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'wiki/public' versus '' in the Netlify UI
8:13:30 PM: Different build command detected, going to use the one specified in the Netlify configuration file: './scripts/build.sh' versus '' in the Netlify UI
8:13:30 PM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'git diff --quiet HEAD^ HEAD'
8:13:31 PM: Starting build script
8:13:31 PM: Installing dependencies
8:13:31 PM: Python version set to 2.7
8:13:32 PM: Started restoring cached node version
8:13:35 PM: Finished restoring cached node version
8:13:35 PM: v12.18.0 is already installed.
8:13:36 PM: Now using node v12.18.0 (npm v6.14.4)
8:13:36 PM: Started restoring cached build plugins
8:13:36 PM: Finished restoring cached build plugins
8:13:36 PM: Attempting ruby version 2.7.1, read from environment
8:13:38 PM: Using ruby version 2.7.1
8:13:38 PM: Using PHP version 5.6
8:13:38 PM: Installing Hugo 0.74.3
8:13:38 PM: Hugo Static Site Generator v0.74.3-DA0437B4/extended linux/amd64 BuildDate: 2020-07-23T16:30:30Z
8:13:38 PM: Started restoring cached go cache
8:13:38 PM: Finished restoring cached go cache
8:13:38 PM: go version go1.14.4 linux/amd64
8:13:38 PM: go version go1.14.4 linux/amd64
8:13:38 PM: Installing missing commands
8:13:38 PM: Verify run directory
8:13:40 PM: ​
8:13:40 PM: ────────────────────────────────────────────────────────────────
8:13:40 PM:   Netlify Build                                                 
8:13:40 PM: ────────────────────────────────────────────────────────────────
8:13:40 PM: ​
8:13:40 PM: ❯ Version
8:13:40 PM:   @netlify/build 5.5.7
8:13:40 PM: ​
8:13:40 PM: ❯ Flags
8:13:40 PM:   deployId: 5fcf90f99894060007284772
8:13:40 PM:   mode: buildbot
8:13:40 PM: ​
8:13:40 PM: ❯ Current directory
8:13:40 PM:   /opt/build/repo/wiki
8:13:40 PM: ​
8:13:40 PM: ❯ Config file
8:13:40 PM:   /opt/build/repo/netlify.toml
8:13:40 PM: ​
8:13:40 PM: ❯ Context
8:13:40 PM:   deploy-preview
8:13:40 PM: ​
8:13:40 PM: ────────────────────────────────────────────────────────────────
8:13:40 PM:   1. build.command from netlify.toml                            
8:13:40 PM: ────────────────────────────────────────────────────────────────
8:13:40 PM: ​
8:13:40 PM: $ ./scripts/build.sh
8:13:41 PM: Tue Dec  8 14:43:41 UTC 2020  Starting to check branches.
8:13:41 PM: From https://github.com/dgraph-io/dgraph
8:13:41 PM:    b0334078f..1805f0269  GRAPHQL-861          -> origin/GRAPHQL-861
8:13:41 PM:    b65d3ddd9..97b01e663  aman/script_test_fix -> origin/aman/script_test_fix
8:13:42 PM: Tue Dec  8 14:43:42 UTC 2020  Updating docs for branch: release/v20.07.
8:13:44 PM: fatal: no upstream configured for branch 'master'
8:13:44 PM: Tue Dec  8 14:43:44 UTC 2020  Updating docs for branch: master.
8:13:46 PM: Tue Dec  8 14:43:46 UTC 2020  Updating docs for branch: master.
8:13:48 PM: Tue Dec  8 14:43:48 UTC 2020  Updating docs for branch: release/v20.03.4.
8:13:49 PM: Tue Dec  8 14:43:49 UTC 2020  Updating docs for branch: release/v1.2.2.
8:13:50 PM: Tue Dec  8 14:43:50 UTC 2020  Updating docs for branch: release/v1.1.1.
8:13:50 PM: Tue Dec  8 14:43:50 UTC 2020  Updating docs for branch: release/v1.0.18.
8:13:51 PM: Tue Dec  8 14:43:51 UTC 2020  Done checking branches.
8:13:51 PM: ​
8:13:51 PM: (build.command completed in 10.9s)
8:13:51 PM: ​
8:13:51 PM: ────────────────────────────────────────────────────────────────
8:13:51 PM:   Netlify Build Complete                                        
8:13:51 PM: ────────────────────────────────────────────────────────────────
8:13:51 PM: ​
8:13:51 PM: (Netlify Build completed in 11s)
8:13:51 PM: Caching artifacts
8:13:51 PM: Started saving build plugins
8:13:51 PM: Finished saving build plugins
8:13:51 PM: Started saving pip cache
8:13:51 PM: Finished saving pip cache
8:13:51 PM: Started saving emacs cask dependencies
8:13:51 PM: Finished saving emacs cask dependencies
8:13:51 PM: Started saving maven dependencies
8:13:51 PM: Finished saving maven dependencies
8:13:51 PM: Started saving boot dependencies
8:13:51 PM: Finished saving boot dependencies
8:13:51 PM: Started saving go dependencies
8:13:51 PM: Finished saving go dependencies
8:13:51 PM: Build script success
8:13:51 PM: Starting to deploy site from 'wiki/public'
8:13:52 PM: Creating deploy tree asynchronously
8:13:52 PM: Creating deploy upload records
8:13:53 PM: Starting post processing
8:13:53 PM: Post processing - HTML
8:13:55 PM: Post processing - header rules
8:13:55 PM: Post processing - redirect rules
8:13:56 PM: Post processing done
8:13:56 PM: Site is live ✨
8:13:56 PM: 0 new files to upload
8:13:56 PM: 0 new functions to upload
8:14:48 PM: Finished processing build request in 1m41.012438244s

Hi, @mbj36. If you make the build.ignore command this:

git diff --quiet HEAD^ HEAD

this will check for any changes in the whole repo.

If you want to just check the wiki directory make the check above for the directory of β€œ.” like this instead:

git diff --quiet HEAD^ HEAD .

The dot (.) mean β€œthis directory” on Unix/Linux systems. Because your build directory is already wiki you can use the command above to check if there are changes in that directory or some subdirectory.

If that doesn’t work as required, though, please let us know.

1 Like

That worked @luke

Thank you!

1 Like