Netlify will deploy the website on every commit on master. Many of those commits are made by Renovate, which shouldn't trigger a deploy.
The way it will work is as follow:
We will create a norska-netlify plugin to host all the Netlify-related methods (including the ones from the setup command)
When norska build is running in production mode, it will call for netlify.shouldCancelBuild() and all netlify.cancelBuild() if true
shouldCancelBuild() will first get the last build SHA (using the API), and perform a few comparisons between the current commit and the last deploy
If there are changed in the from directory, then it will build
If norska or dependencies where modified in package.json, it will build
It will accept overriding the list of globs to match and package.json keys to check in norska.config.js. For example it should also check if netlify.toml has changed
It should also accept a custom method to allow specific projects to do their specific tests
The check will involve calling the API to get the SHA, and also calling the API to cancel the build. This will allow all method to be run locally before testing them on Netlify servers, making it easier to test and mock.
Note that Netlify has two built-in ways to cancel a deploy, but I found they were lacking flexibility:
The netlify.toml file can have a build.ignore command to pre-emptively cancel a deploy if it's not needed. It's calling a command, and if it exits with 0, stops the build.
Using netlify plugins, we can have access to preBuild event and easily cancel it from there.
Both method lack context of the current build command being run. In other words, they don't know anything about the norska.config.js file or any commandline arguments passed to norska build, thus can't know which folder to look at. Sure, this could be fixed with extending them with options in case the folder is not the default one, but it would require to change in it two places. I prefer to have it part of the default build:prod method. Added bonus: it will automatically work on every norska website already deployed.
I implemented this logic in the last version. It seems to work well for simple websites for now, and for monorepos, one needs to override the list of files to check
Netlify will deploy the website on every commit on master. Many of those commits are made by Renovate, which shouldn't trigger a deploy.
The way it will work is as follow:
norska-netlify
plugin to host all the Netlify-related methods (including the ones from thesetup
command)norska build
is running in production mode, it will call fornetlify.shouldCancelBuild()
and allnetlify.cancelBuild()
if trueshouldCancelBuild()
will first get the last build SHA (using the API), and perform a few comparisons between the current commit and the last deployfrom
directory, then it will buildnorska
ordependencies
where modified inpackage.json
, it will buildnorska.config.js
. For example it should also check ifnetlify.toml
has changedThe check will involve calling the API to get the SHA, and also calling the API to cancel the build. This will allow all method to be run locally before testing them on Netlify servers, making it easier to test and mock.
Note that Netlify has two built-in ways to cancel a deploy, but I found they were lacking flexibility:
netlify.toml
file can have abuild.ignore
command to pre-emptively cancel a deploy if it's not needed. It's calling a command, and if it exits with0
, stops the build.preBuild
event and easily cancel it from there.Both method lack context of the current build command being run. In other words, they don't know anything about the
norska.config.js
file or any commandline arguments passed tonorska build
, thus can't know which folder to look at. Sure, this could be fixed with extending them with options in case the folder is not the default one, but it would require to change in it two places. I prefer to have it part of the defaultbuild:prod
method. Added bonus: it will automatically work on every norska website already deployed.