- Stable
2.0.1
Toggle Menu
1.93s
70.65s
Quick Tip: Trigger a Netlify Build Every Day
In Quick Tip #007 we talked about migrating away from using a Client-side third-party JavaScript widget to display GitHub stargazer counts and towards a Data fetched at Build time approach.
Updating this data at build time means that the data isn’t necessarily “live” (although the counts are likely cached at by at least one of the upstream dependencies of this widget, with a frequency that is out of your control).
I’m comfortable with these numbers being a little delayed (more than the JS widget method was) and with this new approach I get more control over the frequency of updates BUT I do probably want to run the build at least once a day. To do this, I used an IFTTT applet to trigger my Netlify build to run every morning using Netlify’s Build Hooks.
Many other services also provide build hooks and/or scheduled builds!
Heavily inspired by Phil Hawksworth’s work on RSS Jamstack.
Step 1 Create a Build Hook
- Go into your Netlify site’s
Build & Deploy
settings - Select
Continuous Deployment
- Add a
Build hook
- Name it
Deploy every day
(or whatever you’d like) - I selected the
main
branch for my site. - Save this and it will provide you with a long URL a la
https://api.netlify.com/build_hooks/SOME_ID_HERE
. This is the URL you want.
Step 2 Schedule the Hook Trigger
Here are a few options to trigger your build hook:
- Use cron-job.org to dynamically trigger your build hook.
- Use IFTTT (mini-tutorial below).
Mini-Tutorials
IFTTT
- Go to
New Applet
on ifttt.com - Click
+this
- Select the
Date & Time
service - Select the
Every day at
option (or whatever frequency you’d like) - Select the time you’d like the build to run.
- Click
+that
- Select the
Webhooks
service - Select the
Make a web request
option - For the URL field, use the Build Hook URL you’ve already retrieved from Netlify.
- For the Method field, choose
POST
. - For the Content Type field, choose
application/x-www-form-urlencoded
. - For the Body field, type
{}
. - Click the
Create action
button. - Click
Finish
.
All Quick Tips
- Quick Tip: Inline Minified CSS
- Quick Tip: Add Edit on GitHub Links to All Pages
- Quick Tip: Inline Minified JavaScript
- Quick Tip: Zero Maintenance Tag Pages for your Blog
- Quick Tip: Super Simple CSS Concatenation
- Quick Tip: Adding a 404 Not Found Page to your Static Site
- Quick Tip: Fetch GitHub Stargazers Count (and More) at Build Time
- Quick Tip: Trigger a Netlify Build Every Day
- Quick Tip: Cache Data Requests
- Quick Tip: Transform Global Data using an `eleventyComputed.js` Global Data File
- Quick Tip: Use local plugins to reduce config file size
- Quick Tip: Draft Posts using Computed Data
- View all of the Eleventy Quick Tips.