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:

on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '*/15 * * * *'

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:

name: Shedule Netlify Build
on:
schedule:
- cron: '0 6 * * *'
jobs:
build:
name: Request Netlify Webhook
runs-on: ubuntu-latest
steps:
- name: Curl request
run: curl -X POST -d {} HERE-GOES-YOUR-BUILD-HOOK

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/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Mobile Application Testing | Challenges and Solutions

Learning Golang with HackerRank — #9 Grading Students

Multilogin 5.5 Unity STABLE Release: API Changes

Building a GitHub Ecosystem as CS Fresher

Android development with MVVM and Kotlin

Serverless Big Data? Start here 💎 AWS Glue, Athena & QuickSite

Docker — How Does Container Access Outside World?

R plus Magento 2 REST API revisited: part 1- authentication and universal search

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

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/

More from Medium

What is JWT. How to implement JWT based authentication in NodeJs?

How to implement JWT based authentication in NodeJs

How TomTom Maps APIs Enable Just-in-Time Construction Material Delivery

Building a CRUD API with Node.js and MongoDB

Beginners guide to authentication and authorization in the Client-Server model.