Scheduled GitHub Actions

For FormBus, I used two GitHub workflows. One is for code quality check by running ESList. The other is to publish a new version of the package on npm.

Both workflows are triggered when a commit is pushed to a branch. While everything happens without any extra effort, I'm the one who is initializing the events.

But GitHub Actions are not limited to these kinds of workflows. You can also schedule events. You can run workflows at specific intervals, and this opens up new possibilities for automation.

Because you can choose to run a Ubuntu image, you can do almost anything with a bit of scripting.

For example, you can rebuild your website every midnight on Netlify. Simply use curl to hit a webhook.

name: Scheduled workflow
- cron: '0 0 * * *'
name: Rebuild website
runs-on: ubuntu-latest
- name: Build hook request
run: curl -X POST -d '{}'

Sometimes it takes a few hours or even half a day until the cron event is registered and run for the first time on GitHub.

You can always make sure that your workflow works as expected by manually running it. Add the additional workflow_dispatch as an event trigger:

name: Scheduled workflow
+ workflow_dispatch:
- cron: '0 0 * * *'

Back to all posts

implenton is my (Mészáros Róbert) online web development-related presence, playground, and the name of my company of one.