DEV Community

Cover image for GitHub Action Schedules
Tina Huynh
Tina Huynh

Posted on

GitHub Action Schedules

Table of Contents

  1. GitHub Actions
  2. GitHub Actions Schedules

GitHub Actions

GitHub actions was launched in 2018 to help developers automate their workflows and goes beyon the typical testing, building, and deploying. It supports C, C++, C#, Java, JavaScript, PHP, Python, Ruby, Scala, and TypeScript. GitHub actions brings automation into the development cycle through event-driven triggers and can range from creating a pull request for building a new brand in a repository.

All GitHub actions are handled via YAML files stored in .github/workflows directory. Every workflow consists of:

  • Events = triggers that start the workflow
  • Jobs = steps that execute
  • Steps = individual tasks that run commands
  • Actions = a command that's executed
  • Runners = a GitHub Actions server

GitHub actions is completely free and available to use on any public repository and self-hosted runner. With the free plan, there is 500MB of workflows.

GitHub Action Schedules

The word schedule defines when your workflow runs on. Let's take a look at this:

name: run this thing every 60 minutes
on:
    schedule:
        - cron: "*/60 * * * *"
Enter fullscreen mode Exit fullscreen mode

When you type this into your YAML file, a blue squiggly line will appear below "*/60 * * * *". If you hover your mouse over this area and your cursor turns into the question mark/hook icon, you will get a pop-up with the schedule you've set. In this case it would say "Runs every hour, on the hour. Actions schedules run at most every 5 minutes."

If you want to change the schedule to your needs, the asterisks work like so:

*    *    *    *    * 
┬    ┬    ┬    ┬    ┬
│    │    │    │    └─  Weekday  (0=Sun .. 6=Sat)
│    │    │    └──────  Month    (1..12)
│    │    └───────────  Day      (1..31)
│    └────────────────  Hour     (0..23)
└─────────────────────  Minute   (0..59)
Enter fullscreen mode Exit fullscreen mode
Operator Description
* all values
, separate individual values
- a range of values
/ divide a value into steps

Here are some examples that may help

Example Description
0 * * * * every hour
*/15 * * * * every 15 mins
0 */2 * * * every 2 hours
0 18 * * 0-6 every week Mon-Sat at 6pm
10 2 * * 6,7 every Sat and Sun on 2:10am
0 0 * * 0 every Sunday midnight
--- ---
@reboot every reboot

Each is considered an allotted time period and are based in UTC timezone. Be careful because some of you may need to do some timezone conversions!

Check out these articles by @kalashin1 and @himanshugarg574

Happy coding!

Oldest comments (0)