Never Miss a Day Again: Automate Your GitHub Streak with Actions

Does seeing an all-green contribution graph on GitHub make you feel accomplished?
Have you ever tried to maintain a streak, only to miss a day because… life happened?

Maybe you were busy. Maybe you lacked motivation.
Or maybe, just maybe, you want to brag about a 365-day streak without sweating over it daily.
No judgment. I got you.

Today, I’m going to show you how to use GitHub Actions, that mysterious tab most of us have seen but never clicked. To automate your daily commits.

Yes, it’s free. Yes, it’s built into GitHub. And no, it’s not as scary as it sounds.

So what are GitHub actions?

GitHub actions is an automation tool integrated inside GitHub that enables you do perform automations with the code in your repository. You can tell it to do multiple things like:

  • “Hey! Run these tests before pushing into the branch!”

  • “Deploy my website to an EC2”

  • “Send my friends an email everyday”

  • or in our case “Auto commit on a repository to maintain a streak”

In short, GitHub actions is a CI/CD automation tool built into GitHub. It can do more than these things. Actions provide a virtual runner (virtual machines) where you can run scripts and code of all kinds. Actions let you define something called a workflow using yaml files, that you can run in schedule, or even trigger manually or after some events like a pull request or push.

Few important components

  • Trigger: When should this workflow run? (e.g., daily at 6 AM, or on push)

  • Jobs: What do you want to do? (e.g., run a script, build code)

  • Steps: Step-by-step instructions for what the job does

  • Runners: GitHub gives you free virtual machines to run all of this (no setup needed)

These components are defined in the yaml file which we will take a look at later.

Actual steps

Step 1: Create a repository

We will start with a text file called activity.txt, that has Day Count: 1 initially. The idea is to update the day count value each day using GitHub actions to maintain the streak.

mkdir commit-streak
cd commit-streak
git init
echo "Day Count: 1" > activity.txt
git add .
git commit -m "Initial commit"

Step 2: The workflow file

Structure the workflow file. I will not get into detail about the bash scripts used here.

name: Daily Auto Commit

#explicitly ask for write access
permissions:
  contents: write

on:
  schedule:
    - cron: '0 6 * * *'  # Every day at 6:00 UTC
  workflow_dispatch:      # Optional manual trigger

jobs:
  auto-commit:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Read and increment daily counter
        run: |
          FILE="activity.txt"
          if [ ! -f "$FILE" ]; then
            echo "Day Count: 1" > $FILE
          else
            COUNT=$(grep -oP '^Day Count: \K\d+' $FILE || echo 0)
            COUNT=$((COUNT + 1))
            sed -i "s/^Day Count:.*/Day Count: $COUNT/" $FILE
          fi
          echo "Last updated: $(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $FILE

      - name: Commit changes
        run: |
          git config user.name "siddhi47"
          git config user.email "siddhikiran.bajracharya@gmail.com"
          git add activity.txt
          git commit -m "📈 Day $(grep -oP '^Day Count: \K\d+' activity.txt): Daily commit" || echo "No changes to commit"

      - name: Push changes using PAT
        env:
          TOKEN: ${{ secrets.PAT_TOKEN }}
        run: |
          echo ${TOKEN}
          git remote set-url origin https://x-access-token:${TOKEN}@github.com/siddhi47/commit-streak.git
          git push

This is a little script we will use to run every day at 6:00 AM (UTC). Be sure to replace the github repository link!

Here’s what it does, step by step:

  1. Opens up your repo

  2. Looks for a file called activity.txt

    • If it doesn't exist, it creates it and sets the count to 1

    • If it does exist, it increases the “Day Count” by one

  3. Adds today’s date and time to the file

  4. Commits that file to your repo with a message like:

    "📈 Day 12: Daily commit"

  5. Pushes the commit back to GitHub using your secret access token

And just like that, your GitHub contribution graph gets a new green square — without lifting a finger.

Step 3: Setting up access tokens

Whenever you want to push into the repository, GitHub makes sure that the things getting pushed is coming from a trusted source. GitHub treats actions as an outsider that is trying to modify your repository. So we have to use an access token. Notice this line:

env:
     TOKEN: ${{ secrets.PAT_TOKEN }}

Essentially, we’re creating a Personal Access Token (PAT) in GitHub and storing it in the secret storage of our GitHub Actions.

Go to https://github.com/settings/personal-access-tokens. Create a token. A token can be set to expired after certain time.

Select your repository and add permissions. The permission should be given on Contents for read and write.

Once you have created the token, copy it! A token once generated can not be viewed later.

Go to the repository, and under Secrets and variables→New repository secret, add a new secret and name it PAT_TOKEN.

Step 4: Automate and trigger

Now your script will run 6 am every morning. You can also test it out by manually trying to execute it. I will leave you guys to figure out.

Caveats!

Before you dive into automating your commits, here are a couple of things you should know:

1. Keep it Personal

Only use this kind of automation in your own personal repositories.
Yes, it looks cool to have a streak, but doing this in:

  • Public open-source projects

  • Work repositories

  • Collaborative codebases

…can be off-putting to others and seen as spammy.

This tutorial is meant for learning purposes, for fun, or for those of us who just want to experiment with GitHub Actions.


2. GitHub Actions Aren’t Unlimited

While GitHub Actions are free (especially on public repos), they do come with monthly usage limits:

  • Free accounts get 2,000 minutes (33 hours) per month

  • They reset monthly, but they’re shared across all your workflows and repos

  • If you’re part of a team or organization, those minutes may be shared across multiple people

So while it's tempting to create lots of automated workflows, it’s a good idea to be mindful, especially in shared or paid setups.

This script is lightweight and runs just once a day for a few seconds, so it’s perfectly fine, but don’t go wild with long-running or resource-heavy automation unless you really need them.

You want to be on a commit streak. Don’t be a commit freak!

0
Subscribe to my newsletter

Read articles from Siddhi Kiran Bajracharya directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Siddhi Kiran Bajracharya
Siddhi Kiran Bajracharya

Hi there! I'm a machine learning, python guy. Reach out to me for collaboration and stuff! :D