Publishing Jigsaw Posts With Netlify Build Hooks

Mon 8th June 2020 By David T. Sadler.

A previous post talks about how I use Jigsaw's filtering to schedule future posts. However because Jigsaw is a static site builder I have to run Jigsaw in order to generate the HTML for the site. So if for example I have scheduled three posts to be published over three consecutive weeks I would need to build and deploy the site on each of the scheduled dates in order for the posts to be published. This kind of defeats the point of scheduling posts. So what I needed was some way to automatically trigger new builds of the site and since I use Netlify to host the site I can make use of their build hooks to do this.

For those that don't know build hooks are URLs you can use to trigger new builds and deployments in Netlify. By making a HTTP POST request to a URL, Netlify will pull down the latest master branch of your site, build it, and then deploy it.

Creating the build hook was simple. After logging into my Netlify account I went to Settings > Build & deploy > Continuous deployment > Build hooks.

From there I clicked Add build hook where I could then provide a name and select which GitHub branch would be used to build the site.

Clicking Save creates the build hook and you are given a unique URL that can be used to trigger it.

What is very handy about Netlify is that they provide you with an example of calling the URL with cURL. With this I simply setup a cron on a server that requests this URL every Monday at 8am.

8 * * 1 curl -X POST -d {} https://api.netlify.com/build_hooks/111111111111111111111111

The result is that every week posts that have been scheduled for that day will now be published when the site is built and deployed by the build hook.

Links

2020-06-01 - Scheduling Posts in JigsawJigsaw - Static Site Generator for PHP Developers.Netlify - Serverless Platform for Static Websites.Build Hooks in Netlify.Netlify - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.