How To Schedule Netlify Builds For Your Website

Services

22/03/2021


At the time of this writing, Netlify does not offer any feature that allows you to schedule builds and deployments. Fortunately, there are free tools that allow us to accomplish the same thing.

I previously wrote an article on how to create and schedule future blog posts in Gatsby, which complements this one.

Add a Netlify build hook

The first step to achieving out goal is to create a netlify build hook. You can do so under Site settings > Build & deploy > Continuous deployment > Build hooks. Simply give your hook a name and which git branch it should build, and Bob's your uncle! 👴

You should then see a link similar to this:

TEXT
https://api.netlify.com/build_hooks/xxxxxxxxxxxxxx

Make sure you have under Continuous deployment > Build settings "Activate builds" selected or else the build hook will not work.

Trigger the hook

There are a plethora of tools you can use to trigger your build hook, for example Zapier, IFTTT or EasyCron. What you choose is more a choice of preference as they all get the job done, with the free tier being completely sufficient for even daily builds.

In my case, I went for IFTTT.

Create a new applet and add a "If This".

Interface of create a new applet in IFTTT

No thanks, I shall stay with the free tier 😛

After that, you need to select a service which should go after the name "Date and Time".

IFTTT applet date and time service

Then you have the option to choose between the frequency of your posts. As I want to trigger a build every Monday and Thursday, I opt for Every day of the week at. Afterwards, you will have have to select a timezone for your cron job as well as define the exact time and day of its trigger. No rocket science so far, right? 🚀

You're greeted once again by the previous interface, only this time you choose "Then That".

Interface of adding Then That in IFTTT applet

However, this time you select the "Webhooks" service.

IFTTT applet webhooks service

Click through some stuff and you'll finally land on this page.

IFTTT applet webhooks service configuration

In the URL field, paste your build hook URL that we discussed earlier and set "Method" to POST. For "Content Type", select application/x-www-form-urlencoded and lastly for "Body" enter {}. A few more clicks et voilà, you're done!


WRITTEN BY

Code and stuff