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
  - cron: '30 3 * * *'
    runs-on: ubuntu-latest
    - name: Trigger our build webhook on Netlify
      run: curl -s -X POST "${TOKEN}"
        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.