⚠️ This lesson is retired and might contain outdated information.

Scheduling GitHub Actions with cron

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet

GitHub Actions can be triggered to run on a schedule using cron syntax. In this video we go over what that means and how to write cron syntax. We also show a tool and a series of examples to aid in writing and debugging cron.

  • https://crontab.guru/

Instructor: [00:00] In addition to triggering GitHub actions on push, we can schedule GitHub actions to occur using cron syntax. Note that scheduled workflows will get run with the latest commit on the default branch.

[00:11] To understand how to schedule GitHub actions using cron, we can use crontab guru. Crontab guru will show us a minute, hour, day, month, and day of the week. Using this display, we can click on the field that we want to change, look at the options available to us, and choose one.

[00:31] Note that now the next time this cron job will run is at 2:05. Crontab guru has a set of examples that can be found. If you want to run ever Friday, every hour at 30 minutes, or every day at 1:00 AM. Let's look at the every five minutes.

[00:47] The syntax to run every five minutes uses a star, a slash, and a five in the minute category. All of the other fields will be set to any value. Let's go to our GitHub workflow.

[01:00] This GitHub workflow runs echo. Currently, our workflow is run on push. Let's change that.

[01:08] We'll change this to run on schedule. Note that we have to wrap our string in quotes because star is a special character in YAML. We'll commit this.

[01:26] Let's go back to our actions tab. The workflow now runs on a schedule. Note that our action is now running every five minutes.