Schedule Netlify builds with GitHub Actions

Photo by Richy Great on Unsplash

If you didn’t already know it, GitHub Actions is a way to automate things in your GitHub repository. With it you can create workflows that can do things with your repository and react to different kinds of events. The easiest way to setup a scheduled build hook trigger that I have come across is to use GitHub Actions.

The schedule event allows you to trigger a workflow at a scheduled time. You can schedule a workflow to run at specific UTC times using POSIX cron syntax. Scheduled workflows run on the latest commit on the default or base branch. The shortest interval you can run scheduled workflows is once every 5 minutes.

This example triggers the workflow every 15 minutes:

What are Netlify Build hooks?

Build hooks are URLs you can use to trigger new builds and deploys. You can find them in Netlify dashboard: Site settings > Build & deploy > Continuous deployment > Build hooks. By creating a build hook and sending a POST request to it, you trigger a new build & deploy for your site.

Workflow file

In your GitHub repo, create a main.yml file in a .github/workflows directory:

Replace HERE-GOES-YOUR-BUILD-HOOK with the build hook url you created in Netlify dashboard. Now site will rebuild every morning, I hope this is useful to you!

--

--

I drink a lot of tea and build beautiful websites. If you are looking to work together or just start a conversation 👉 https://www.ronaldsvilcins.com/

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
Ronalds Vilcins

I drink a lot of tea and build beautiful websites. If you are looking to work together or just start a conversation 👉 https://www.ronaldsvilcins.com/