Scheduling Deploys with GitHub Actions

Leveraging GitHub Workflows’ Scheduled Events (read: cronjobs that run on GitHub) the folks at De Voorhoede let their static site automatically be rebuilt overnight. They do this because they have some external content, which doesn’t get committed into the repo, included on their site.

Static websites don’t update by themselves. In case of code changes (git push) and content changes (CMS publish event) a user triggers an update. But what if an external system (regularly) updates but can’t be configured to trigger an update? Enter cron jobs.

As their site is deployed onto Netlify, they let GitHub perform a curl request to Netlify’s Deploy Webhook, thus rebuilding and redeploying their site.

Their workflow file .github/workflows/nightly-build.yml is straightforward:

name: Scheduled build
on:
  schedule:
  - cron: '30 3 * * *'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Trigger our build webhook on Netlify
      run: curl -s -X POST "https://api.netlify.com/build_hooks/${TOKEN}"
      env:
        TOKEN: ${{ secrets.NETLIFY_CRON_BUILD_HOOK }}

The required NETLIFY_CRON_BUILD_HOOK is stored a GitHub Secret into the repo

Scheduling Netlify deploys with GitHub Actions →

💁‍♂️ Here’s a writeup I’ve done on deploying a static site onto Netlify, in case you’re looking for info on how to get started with Netlify.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.