🎁

12 Days of Baddass Courses sale! Get instant access to the entire egghead library of courses and lessons for 58% off.

Runs out in:
05 : 14 : 04 : 40
1×
Become a member
to unlock all features
Autoplay

    Scheduling GitHub Actions with cron

    Chris BiscardiChris Biscardi
    githubGitHub

    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.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: 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.

    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.

    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.

    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.

    This GitHub workflow runs echo. Currently, our workflow is run on push. Let's change that.

    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.

    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.