How I Built a Daily Streak Keeper with Python & GitHub Actions

Published: (January 16, 2026 at 06:06 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

The Idea

The goal was simple:

  • Fetch a daily quote (to make the commit meaningful).
  • Update the README.md with the new quote.
  • Commit and push the changes automatically every day.

The Tech Stack

  • Python – to fetch the quote and update the file.
  • GitHub Actions – to schedule the script to run daily.

The Code

Python Script (update_quote.py)

import requests
import datetime

def get_quote():
    url = "https://dummyjson.com/quotes/random"
    try:
        response = requests.get(url)
        if response.status_code == 200:
            data = response.json()
            return f"\"{data['quote']}\"{data['author']}"
        else:
            return "Could not fetch a quote today. Keep coding!"
    except Exception as e:
        return f"Error fetching quote: {e}"

def update_readme(quote):
    date_str = datetime.datetime.now().strftime("%Y-%m-%d")

    # Template for the README
    readme_content = f"""
🚀 Daily Streak Keeper

This repository automatically updates itself every day at 12:00 PM Nairobi Time to keep my GitHub contribution streak alive.

📅 Quote for {date_str}

> {quote}

---
Last updated automatically by GitHub Actions.
"""

    with open("README.md", "w", encoding="utf-8") as file:
        file.write(readme_content)

if __name__ == "__main__":
    quote = get_quote()
    update_readme(quote)

Automation (daily-quote.yml)

name: Daily Quote Update

on:
  schedule:
    # 09:00 UTC = 12:00 PM Nairobi Time
    - cron: '0 9 * * *'
  workflow_dispatch:

jobs:
  update-readme:
    runs-on: ubuntu-latest
    permissions:
      contents: write

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

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'

      - name: Install dependencies
        run: |
          pip install -r requirements.txt

      - name: Run Python script
        run: |
          python update_quote.py

      - name: Commit and Push
        run: |
          git config --global user.name "Quote Bot"
          git config --global user.email "${{ github.actor }}@users.noreply.github.com"

          git add README.md
          if git diff-index --quiet HEAD; then
            echo "No changes to commit"
          else
            git commit -m "Daily Quote: Updated README with new inspiration 📜"
            git push
          fi

Conclusion

This small project keeps my profile active while delivering a fresh quote each day. It demonstrates how powerful and easy GitHub Actions can be for automating simple tasks.

Check out the code in the repository and feel free to fork it to create your own streak keeper.

Back to Blog

Related posts

Read more »