Scheduling Webhook and API Calls With GitHub Actions

Lloyd Atkinson

GitHub Actions are a great way to automate workflows and build pipelines. For example, I previously discussed using GitHub Actions to automate labels on pull requests. This time, I will be showing how to schedule Webhook/API calls on a schedule.

It’s straightforward to set up, so this will be a short post. I will use one of the GitHub Actions workflows I use on this site to demonstrate. I wished to build my site automatically once a day. Although it is built and deployed automatically on push anyway, I recently added the ability to display the number of times site visits have read an article. I didn’t want to have to wait for a push to see the updated number of views.

name: Scheduled Build

on:
  schedule:
    - cron: '0 9 * * *'
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Netlify Webhook
      run: |
        curl -X POST https://api.netlify.com/build_hooks/<id>

Share:

Need help with your software project? Let's talk

Stay up to date

Subscribe to my newsletter to stay up to date on my articles and projects

© Lloyd Atkinson 2023

I'm avaliable for work 💡