Ability to skip deploy preview builds if base directory contents haven't changed

Currently netlify supports monorepos by not rebuilding apps if base directory of that app hasn’t changed. But deploy previews builds an app every time new PR is made regardless of contents of base directory of that app has changed or not.

Let me describe our use case: we have monorepo with server, admin, kitchen, and pos subfolders. Admin, kitchen, and pos apps wired to 3 separate netlify apps for CD and Deploy Previews. Now when developers create a PR with only server related changes, all 3 apps generated Deploy Previews for that PR. (Also sometimes they builds it again on commits to that PR ignoring previous builds).

Would be great if we could achieve following:

  1. Don’t build any Deploy Previews if PR changes only the contents of server folder.
  2. If new PR made with changes to admin folder, generate Deploy Previews only for admin app.

Otherwise we’re enjoying it so far :+1:.

You can certainly write an ignore script to check this, @almas :

https://docs.netlify.com/configure-builds/file-based-configuration/#ignore-builds

Will that workflow not be possible for you? I understand you’d like your config to be handled automagically and so would we all, but in this case you’ll have to do a bit of work since we made a “one size could fit all” feature :slight_smile:

Hey, could you please provide more info on deploy context. I saw https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables, but not yet sure how would I get the previous build context. Does netlify do git clone build branch?

Also it suggests to add following to netlify.toml

[build]
  ignore = "git diff --quiet HEAD^ HEAD sub_dir/"

How can I get access to the base directory for current app, if it’s monorepo, or am I already inside?

You wouldn’t get the previous build context; it shouldn’t matter. We store separate cache for each context already :slight_smile:

You could use a command like pwd to get the current directory if you need it. Your build will START from within the base directory, so hopefully that’s the information you need to build a solution without resorting to tactics like that though.