Limit build minutes / smartly build projects

Hi!

I was wondering if it’s possible to limit a particular project to, say, X builds / day.

Similarly, I was wondering if it was possible to auto-detect project changes and either build or not build accordingly. For example, if I have a monolith project (frontend and backend) and I only want to rebuild the project when the frontend changes, would you have any recommendation on how to do that easily / automatically?

Thank you!

Hi there, I don’t have specific answers at this time, but, this thread:

is a great starting point for optimizing builds, as is this one:

Hi! This has helped a bit, I realize I could turn off deploy previews for a handful of my projects that are fairly low traffic but build intensive.

I’m still not sure what to do with my monorepos, though. Maybe I should make Travis CI send a notification via webhook if my client changes? Is there an example of something like that?

Hi, @seiyria. For monorepos, our build in method for testing when to build is the setting build.ignore. Here is an example from a netlify.toml file:

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

The build ignore command works be checking the exit code of the command run. In the git diff command above, the exit code will be non-zero if there has been a change somewhere in that subdirectory (sub_dir/) between the most recent commit and its parent commit.

I point out the “non-zero” because, in most cases, a non-zero exit code means an error and, in most cases, a process will stop on a non-zero exit.

With build.ignore, the non-zero means there is a difference which is what we testing for and we only want to build if that difference exist. So, the build.ignore continues on a non-zero exit - instead of stopping. (This is just something to keep in mind when writing custom build.ignore commands.)

Regarding limiting to X builds a day, there is no such option at this time.

If there are other questions about this, please let us know.

@luke thank you! this helps a lot.