Skip to main content

On This Page

Automating GitHub Profile README with GitHub Actions

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

Automating GitHub Profile README with GitHub Actions

BHARGAB KALITA automated his GitHub profile README to display latest Dev.to articles using GitHub Actions. The workflow runs daily, updating the README without manual intervention.

Why This Matters

GitHub Actions enables seamless automation of repetitive tasks, but real-world implementation requires handling API rate limits, environment variables, and error resilience. A misconfigured workflow could lead to stale content or failed deployments, costing time to debug.

Key Insights

  • “GitHub Actions workflow for Dev.to updates, 2025”: Example from BHARGAB KALITA’s implementation
  • “Sed command for markdown replacement”: Used to dynamically update README sections
  • “GitHub Actions as free cron server”: Enables scheduled tasks without infrastructure

Working Example

name: Update README with latest Dev.to Post
on:
  schedule:
    - cron: '0 0 * * *'
  workflow_dispatch:
jobs:
  update-readme:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Repository
      uses: actions/checkout@v3
    - name: Fetch Latest Dev.to Posts
      id: fetch_dev_posts
      run: |
        DEVTO_USERNAME="bhargab"
        API_RESPONSE=$(curl -s "https://dev.to/api/articles?username=${DEVTO_USERNAME}")
        TITLE_1=$(echo $API_RESPONSE | jq -r '.[0].title')
        URL_1=$(echo $API_RESPONSE | jq -r '.[0].url')
        DATE_1=$(echo $API_RESPONSE | jq -r '.[0].published_at' | cut -d'T' -f1)
        # ... (similar for titles 2-3)
        echo "title_1=$TITLE_1" >> $GITHUB_ENV
        # ... (set all variables)
    - name: Update README
      run: |
        README_FILE="./README.md"
        NEW_CONTENT="- [${{ env.title_1 }}](${{ env.url_1 }}) - Published on ${{ env.date_1 }}\n- [${{ env.title_2 }}](${{ env.url_2 }}) - Published on ${{ env.date_2 }}\n- [${{ env.title_3 }}](${{ env.url_3 }}) - Published on ${{ env.date_3 }}"
        sed -i '/<!-- LATEST_DEVTO_POST -->/{n;N;N;s|.*|'"$NEW_CONTENT"'|}' $README_FILE
    - name: Commit Changes
      run: |
        git config --local user.name "github-actions[bot]"
        git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
        git add README.md --force
        git commit -m "Update README with latest 3 Dev.to posts" || echo "No changes to commit"
        git push

Practical Applications

  • Use Case: Automating Dev.to article updates in GitHub profiles
  • Pitfall: Hardcoding API keys in workflows leads to security risks

References:


Continue reading

Next article

How I Stopped AI Codebases From Collapsing: Architecture Drift vs. Deterministic Slices

Related Content