Using the ignore option in netlify.toml for conditional builds

Hello,

I’m trying to use the ignore option in my netlify.toml file, but it doesn’t seem to be working. Here’s a link to my pull request on GitHub: Update publish directory for docs via Netlify by Zhao-Andy · Pull Request #7825 · forem/forem · GitHub

I noticed that Netlify’s docs about this say that I might need to relink my repo if it was created before October 2019, which my repo was. Not sure if I relinked it properly though. I simply went to:

  1. Deploy settings
  2. “Edit settings”
  3. “Link to a different repository”
  4. added my repo again

and it seemed to rebuild properly.

One last thing: I’m thinking the ignore option is not working because my deploy preview for the PR linked above is still building, and I’m assuming it shouldn’t because of the ignore option I added. Maybe I’m using the command incorrectly though?

My app is docs.dev.to.

Thanks!
Andy

Edit:

For those curious, my situation is this:

  • we use a monorepo that has a docs/ folder, which is connected to a Netlify app
  • we only need to build our Netlify app whenever there are changes with in that docs/ folder
  • I added the ignore attribute to my netlify.toml file:
[build]
  base = "docs/"
  command = "node deploy-script.js"
  ignore = "git diff --quiet master docs/"

...etc.

This ignore option returns an exit code of 0 if there are no changes compared to the master branch and the docs/ folder of the current branch. It returns an exit code of 1 if there are changes.

If you’re trying to do this yourself, you can test your exit codes by doing this in bash – probably works for other shells too but I’m not sure:

git diff --quiet [your-options-here] && echo $?

Along with Luke’s comment from below of making my build image Xenial since I have a monorepo, those should be the steps to get this working. :slight_smile:

Hi @andaizhao. Thanks for asking about this. I replied to you in another channel already as well.

The issue is that this monorepo support is only in the Xenial build image and this site is still on Trusty. Changing to Xenial (in the site build settings in our the web UI) should be all that is required to get this working.

If there are other questions or that change doesn’t fix this issue, please let us know.

1 Like