Hi!
I’m configuring Netlify in a monorepo (site’s name is mezo-dapp
). Initially I didn’u use netlify.toml
config and had everything set up using the UI.
But now I want to change the config in a way that the site will not be built if only files from certain locations have been modified.
So I configured the netlify.toml
this way:
[build]
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ':(exclude)solidity/' ':(exclude)contracts/' ':(exclude).github'/ ':(exclude).vscode/' ':(exclude)README.md' ':(exclude).gitignore' ':(exclude).nvmrc' ':(exclude).pre-commit-config.yaml' ':(exclude).prettierignore' ':(exclude).prettierrc.js' ':(exclude).syncpackrc' ':(exclude)LICENSE'"
My understanding is that this config should skip the building if the diff command returns exit code 0. This particular diff command compares changes between the current and cached commit, but should not compare files from paths marked with the :(exclude)
prefix.
I’ve tested it localle and indeed I was getting exit code 0 when modifying only the “excluded” files.
But when I saved the Netlify config with the ignore
command, the builds are not skipped. For example I have a PR that only modifies files in the solidity/
folder and I can see that the Netlify build was triggered in that PR.
And it’s not an issue of Netlify not seeing the config file - in the log from that deployment I can see that the ‘ignore’ command was picked up:
4:19:45 PM: Resolved config
4:19:45 PM: build:
4:19:45 PM: command: pnpm --filter dapp run build
4:19:45 PM: commandOrigin: ui
4:19:45 PM: environment:
[...]
4:19:45 PM: ignore: git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ":(exclude)solidity/" ":(exclude)contracts/" ":(exclude).github"/ ":(exclude).vscode/" ":(exclude)README.md" ":(exclude).gitignore" ":(exclude).nvmrc" ":(exclude).pre-commit-config.yaml" ":(exclude).prettierignore" ":(exclude).prettierrc.js" ":(exclude).syncpackrc" ":(exclude)LICENSE"
4:19:45 PM: publish: /opt/build/repo/dapp/dist
4:19:45 PM: publishOrigin: ui
Here’s the build config: