Schedule GitHub Actions Utilizing CRON Expressions | by Sarah Lean | Jun, 2022


Set off duties on the identical time daily

You’ll be able to set off GitHub Actions to run on quite a lot of totally different occasions. The most typical could be operating while you push adjustments to your repository. Additionally, you might wish to set off an Motion to run on pull requests.

When constructing Actions you might wish to run them on an outlined schedule. This tutorial reveals you find out how to configure a GitHub Motion on a given schedule utilizing CRON expressions.

Sure, sure you possibly can. You have got the choice to set off a GitHub Actions on a schedule an instance might be:

Instance of scheduling a GitHub Motion workflow with CRON

CRON is a command line utility that’s used to schedule jobs. You’ll hear it referred to CRON jobs or CRON duties.

The CRON syntax can generally be complicated when first encountered. There are 5 sections that may be configured throughout the CRON syntax. You’ll be able to specify day of week, month, day of the month, hour and minute.

This isn’t one thing you should decide to reminiscence however with the ability to learn the syntax is beneficial. Beneath is a good diagram to point out you the way the syntax is damaged down.

CRON Syntax defined

I really like to make use of the web site https://crontab.guru/. You’ll be able to put the syntax in to the web site and it’ll decipher what that schedule would do, or equally you need to use it to construct the appropriate syntax for the schedule you wish to execute.

I wish to present you an instance of a GitHub Actions workflow together with a CRON schedule.

Instance GitHub Motion Workflow triggering on a CRON schedule

The above GitHub Actions workflow will open set off on a schedule. The CRON job I’ve set will run at 11 am on daily of week from Monday via Friday.

The workflow then will run the Code Checkout step on a Ubuntu runner.

It’s a simple workflow, nevertheless it triggers utilizing a CRON schedule fairly than on a push to GitHub or on a pull request.

Remember to try the opposite blogs I’ve written on GitHub Motion makes use of and options.



Leave a Comment