Python과 GitHub Actions로 만든 일일 스트릭 관리기

발행: (2026년 1월 17일 오전 08:06 GMT+9)
3 min read
원문: Dev.to

Source: Dev.to

아이디어

목표는 간단했습니다:

  • 매일 인용구를 가져와서(커밋을 의미 있게 만들기 위해).
  • 새로운 인용구로 README.md를 업데이트합니다.
  • 매일 자동으로 변경 사항을 커밋하고 푸시합니다.

기술 스택

  • Python – 인용구를 가져오고 파일을 업데이트하기 위해.
  • GitHub Actions – 스크립트를 매일 실행하도록 예약하기 위해.

코드

Python 스크립트 (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)

자동화 (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

결론

이 작은 프로젝트는 매일 새로운 인용구를 제공하면서 내 프로필을 활발하게 유지해 줍니다. GitHub Actions가 단순한 작업을 자동화하는 데 얼마나 강력하고 쉬운지 보여주는 좋은 예입니다.

코드는 저장소에서 확인할 수 있으며, 여러분도 포크해서 자신만의 스트릭 키퍼를 만들어 보세요.

Back to Blog

관련 글

더 보기 »