Using build hook payload to trigger a different build command on Netlify

All started by the following tweet:

Reading the Twitter conversation, I wondered if it was possible to pass data to the build hook.

Heading to Netlify documentation I found exactly what I need:

Great! Now the deploy script will look something like:


if [ "$INCOMING_HOOK_BODY" = "full" ]; then
echo "Full build"
gatsby clean && gatsby build
echo "Simple build"
gatsby build

This means:

curl -X POST -d {}

Will execute

gatsby build


curl -X POST -d 'full'

Will execute

gatsby clean && gatsby build

Code example

You can find, bellow, a full example using Github Actions to schedule the build.

Don’t forget to set up the build script on Netlify!

Oh! One last thing!

The best part, for me, is the reply from Jason Lengstorf 😋 😇 😉



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store