DEV Community

Cover image for Commit Cron: A Simple Daily Commit Bot with GitHub Actions
Timothy Jhey Sarmiento
Timothy Jhey Sarmiento

Posted on

Commit Cron: A Simple Daily Commit Bot with GitHub Actions

I built Commit Cron, a small GitHub Actions experiment that creates one automated commit every day.

The project updates a text file with the latest execution time, commits the change using the github-actions[bot] account, and pushes it back to the repository.

View the project on GitHub: Commit Cron

How It Works
The workflow runs every day at 10:00 AM Asia/Manila time.

on:
  schedule:
    - cron: "0 10 * * *"
      timezone: "Asia/Manila"

  workflow_dispatch:
Enter fullscreen mode Exit fullscreen mode

The workflow_dispatch trigger also lets me run the workflow manually from the GitHub Actions tab.

The workflow checks out the repository, creates the bot directory when needed, and updates bot/last-run.txt:

mkdir -p bot

printf "Last automatic update: %s\n" \
  "$(TZ=Asia/Manila date '+%Y-%m-%d %H:%M:%S %:z (Asia/Manila)')" \
  > bot/last-run.txt
Enter fullscreen mode Exit fullscreen mode

The file contains a timestamp similar to:

Last automatic update: 2026-07-17 10:03:24 +08:00 (Asia/Manila)

After updating the file, the workflow configures the GitHub Actions bot identity and creates the commit:

git config user.name "github-actions[bot]"
git config user.email \
 "41898282+github-actions[bot]@users.noreply.github.com"

git add bot/last-run.txt
git commit -m "chore: daily automated update"
Enter fullscreen mode Exit fullscreen mode

Before pushing, it pulls the latest branch changes with rebase:

git pull --rebase origin "${GITHUB_REF_NAME}"
git push origin "HEAD:${GITHUB_REF_NAME}"
Enter fullscreen mode Exit fullscreen mode

This helps prevent the push from failing when another commit is added while the workflow is running.

Repository Structure

.
├── .github/
│   └── workflows/
│       └── daily-commit.yml
├── bot/
│   └── last-run.txt
├── LICENSE
└── README.md
Enter fullscreen mode Exit fullscreen mode

Why I Built It
Commit Cron is a small demonstration of:

  • Scheduled GitHub Actions workflows
  • Manual workflow triggers
  • Automated file updates
  • Bot-generated Git commits
  • Repository write permissions using GITHUB_TOKEN

The workflow uses:

permissions:
  contents: write
Enter fullscreen mode Exit fullscreen mode

This allows the built-in GitHub token to push the generated commit.

Important Note
The automated commits only confirm that the workflow ran successfully.

They do not represent manual development activity or meaningful project contributions.

Scheduled workflows may also start later than the configured time during periods of high demand, which is why bot/last-run.txt records the actual execution time.

Final Thoughts
Commit Cron is a small project, but it is a useful introduction to scheduled GitHub Actions and automated repository updates.

Top comments (0)