Automate Your CI/CD Workflows Using Cron Jobs in GitHub Actions

CI/CD is all about automation. We want our code to be built, tested, and deployed without manual intervention. But what if we want this automation to run at a specific time every day, every week, or even every minute? That’s where cron jobs come in.
In GitHub Actions, we can schedule workflows using the schedule
event, which uses cron syntax—the same style used in Linux servers.
What is Cron?
Cron is a time-based job scheduler. It allows you to run commands or scripts automatically at specific times or intervals.
The cron syntax looks like this:
* * * * *
│ │ │ │ │
│ │ │ │ └─── Day of the week (0 - 6) (Sunday = 0)
│ │ │ └───── Month (1 - 12)
│ │ └─────── Day of the month (1 - 31)
│ └───────── Hour (0 - 23)
└─────────── Minute (0 - 59)
For example:
0 9 * * *
→ Run at 9:00 AM every day0 0 * * 0
→ Run at midnight every Sunday*/15 * * * *
→ Run every 15 minutes
Scheduling Workflows in GitHub Actions
In GitHub Actions, the schedule
keyword lets you automatically trigger workflows at specific times.
Here’s a simple example:
name: Daily CI
on:
schedule:
- cron: '0 9 * * *' # Runs every day at 9 AM UTC
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Run Tests
run: npm test
✅ Explanation:
on: schedule
→ Tells GitHub Actions to run this workflow automatically based on a cron schedule.cron: '0 9 * * *'
→ This workflow runs every day at 9:00 AM UTC.Jobs → Just like any other workflow, you can define build, test, and deploy steps.
No human intervention is needed. The workflow runs automatically according to the schedule.
Why Use Scheduled Workflows?
Here are some common use cases:
Running nightly tests:
0 2 * * *
→ Run tests at 2 AM every night.Deploying a daily build:
0 7 * * *
→ Automatically deploy daily at 7 AM.Sending automated reports:
30 8 * * 1
→ Send reports every Monday at 8:30 AM.Cleaning temporary files or databases periodically.
Visualizing the Cron Workflow
Here’s a diagram of how GitHub Actions cron works:
[Diagram Placeholder – polished version can be added using tools like Figma or Canva]
┌───────────── Schedule Trigger (Cron)
│
│
▼
┌─────────────┐
│ GitHub Repo │
└─────────────┘
│
▼
┌─────────────┐
│ Workflow CI │
│ Jobs Run │
└─────────────┘
│
▼
┌─────────────┐
│ Build/Test │
│ Deploy │
└─────────────┘
│
▼
✅ Done
Explanation:
GitHub checks the cron schedule every minute.
If the time matches, the workflow is triggered automatically.
The workflow executes your defined jobs: build, test, deploy.
Everything happens without human intervention.
Tips for Using Cron in GitHub Actions
Use UTC: GitHub Actions uses UTC timezone. Convert your local time accordingly.
Be mindful of frequency: The minimum interval is 1 minute. Too frequent schedules may hit API rate limits.
Combine with manual triggers: You can add
workflow_dispatch
so you can also trigger the workflow manually if needed.Use secrets: Don’t hardcode credentials; use GitHub Secrets for secure deployments.
Example: Combine Cron with Manual Trigger
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run'
required: true
default: 'main'
schedule:
- cron: '0 9 * * *'
✅ Here, your workflow can run:
Automatically at 9 AM every day (cron)
Or manually through GitHub UI (workflow_dispatch)
Key Takeaways
Cron jobs in GitHub Actions let you schedule workflows without human intervention.
The
schedule
keyword uses standard cron syntax.Combine with
workflow_dispatch
for flexible manual + automated execution.Perfect for nightly builds, deployments, and automated reports.
💡 Pro Tip for Students:
Think of cron jobs as your personal robot assistant that runs repetitive tasks for you at the exact time you want, so you can focus on coding and learning new skills!
Subscribe to my newsletter
Read articles from Muhammad Sufiyan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Muhammad Sufiyan
Muhammad Sufiyan
As a former 3D Animator with more than 12 years of experience, I have always been fascinated by the intersection of technology and creativity. That's why I recently shifted my career towards MERN stack development and software engineering, where I have been serving since 2021. With my background in 3D animation, I bring a unique perspective to software development, combining creativity and technical expertise to build innovative and visually engaging applications. I have a passion for learning and staying up-to-date with the latest technologies and best practices, and I enjoy collaborating with cross-functional teams to solve complex problems and create seamless user experiences. In my current role as a MERN stack developer, I have been responsible for developing and implementing web applications using MongoDB, Express, React, and Node.js. I have also gained experience in Agile development methodologies, version control with Git, and cloud-based deployment using platforms like Heroku and AWS. I am committed to delivering high-quality work that meets the needs of both clients and end-users, and I am always seeking new challenges and opportunities to grow both personally and professionally.