How to Use GitHub Actions to Create Cron Jobs for Free


Working with static sites are great until you want to create a task that is automatic, recently i built a next.js site that on schedule checks if a site content has changed and notifies the admin about it via email.
For this i needed a cronjob that will run every 15mins > check the targeted site > notify me via email if target site content changed.
Enter GitHub Actions
GitHub Actions, a feature of GitHub's CI/CD ecosystem, not only automates workflows like testing and deployment but can also run scheduled tasks. In this article, I'll walk you through steps on how to create cron jobs using GitHub Actions for free easily.
Limits
GitHub Actions allows developers to automate tasks based on events in a GitHub repository—such as pushing code, opening pull requests, or on a schedule. Each automation is called a "workflow" and is defined using a YAML file inside the directory .github/workflows/
GitHub provides free usage of GitHub Actions with a generous monthly limits, especially for public repositories. For example, public repos get unlimited free minutes, while private repos get 2,000 minutes/month.
Why Use GitHub Actions for Cron Jobs?
GitHub Actions is a great choice for running cron jobs because it’s free, so no need to manage your own servers, and it integrates directly with version control of github so its easier to manage along with your written code.
Step-by-Step: Creating a Cron Job Using GitHub Actions
- Create a GitHub Repository First go to https://github.com/new and create a new repository for your cron, or you can just use a existing repository you have that you want to use.
If you don’t want your cron job to be public, you can use a private repo (just keep in mind the free minutes limit).
- Add the Workflow File At the root of your repository, create a folder called .github/workflows/ (if it doesn't already exist). Inside this folder, create a YAML file, e.g., cronjob.yml.
File path: .github/workflows/cronjob.yml
- Define the Cron Schedule Here’s a example file that i used for my next.js project, its simple, every 15 mins ping my site's /sync path. Once it does it my next site updates the info.
name: Ping Sync Endpoint
on:
schedule:
- cron: "*/15 * * * *" # every 15 minutes
workflow_dispatch: # allow manual trigger
jobs:
ping:
runs-on: ubuntu-latest
steps:
- name: Call sync endpoint
run: curl -s -o /dev/null -w "%{http_code}" https://example.com/sync
After each run, the job will write a timestamp to a log.txt file—but note that this won’t persist unless you commit it back or upload it as an artifact, since GitHub Actions runners are ephemeral.
Understanding Cron Syntax
Considerations
Before you go wild, keep these limitations in mind:
Limitation Details Time zone - All cron times are in UTC. Adjust accordingly. Ephemeral runners - Files don’t persist unless uploaded or committed. Execution time limit - Each job has a maximum runtime of 6 hours. Scheduled triggers may delay - GitHub does not guarantee exact start time. Free minutes - Public repos are unlimited, but private repos have quotas.