DEV Community

Cover image for How I Automated My GitHub Profile README With GitHub Actions (And How You Can Automate Anything Too)
BHARGAB KALITA
BHARGAB KALITA

Posted on

How I Automated My GitHub Profile README With GitHub Actions (And How You Can Automate Anything Too)

At the end of last year, I started writing a few more articles on Dev.to. I’d been posting for a while, but I’m honestly too lazy to keep updating my GitHub Profile README every time. Opening the repo, editing the README, adding links… it wasn’t difficult, just boring. And boring tasks always make me wonder why I’m still doing them manually.

So I looked around, tried a few things, and with a bit of help from AI, I finally found a way to automate it. After some quick experiments, everything clicked. My profile started updating itself with my latest Dev.to articles. No manual edits. No drama. Just simple automation doing its job.

It was a small win, but it felt great. And that’s what pushed me to share how I did it and what else you can automate using GitHub Actions.

Before You Start: The Special GitHub Profile Repository

This part is important.

GitHub only displays your README as your public profile if you create a repo exactly named after your username.

For example:

  • Username → yourusername
  • Profile repo → also yourusername

If you don’t have this repository yet, create a new public one with the same name as your username. Once it exists:

  • the README becomes your profile README
  • you can add workflows in .github/workflows
  • automation will run exactly like in any other repo

This is the repo where I added my workflow last year, and it’s still running perfectly.


How I Automated My Profile README to Show My Latest Dev.to Articles

The goal was simple:
Show the 3 latest posts from Dev.to in my README without updating anything manually.

I changed my workflow so that it fetches only the latest 3 articles and rewrites the section in my README.

Here’s the complete GitHub Actions workflow.


GitHub Actions Workflow (Shows Only 3 Latest Dev.to Articles)

Create:

.github/workflows/update-readme.yml
Enter fullscreen mode Exit fullscreen mode

Add:

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 (replace the username)
        id: fetch_dev_posts
        run: |
          DEVTO_USERNAME="bhargab"
          API_RESPONSE=$(curl -s "https://dev.to/api/articles?username=${DEVTO_USERNAME}")

          # Get the titles, URLs, and publish dates of the latest 3 posts
          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)

          TITLE_2=$(echo $API_RESPONSE | jq -r '.[1].title')
          URL_2=$(echo $API_RESPONSE | jq -r '.[1].url')
          DATE_2=$(echo $API_RESPONSE | jq -r '.[1].published_at' | cut -d'T' -f1)

          TITLE_3=$(echo $API_RESPONSE | jq -r '.[2].title')
          URL_3=$(echo $API_RESPONSE | jq -r '.[2].url')
          DATE_3=$(echo $API_RESPONSE | jq -r '.[2].published_at' | cut -d'T' -f1)

          # Pass these values to the GitHub environment for use in the next steps
          echo "title_1=$TITLE_1" >> $GITHUB_ENV
          echo "url_1=$URL_1" >> $GITHUB_ENV
          echo "date_1=$DATE_1" >> $GITHUB_ENV

          echo "title_2=$TITLE_2" >> $GITHUB_ENV
          echo "url_2=$URL_2" >> $GITHUB_ENV
          echo "date_2=$DATE_2" >> $GITHUB_ENV

          echo "title_3=$TITLE_3" >> $GITHUB_ENV
          echo "url_3=$URL_3" >> $GITHUB_ENV
          echo "date_3=$DATE_3" >> $GITHUB_ENV

      - name: Update README
        run: |
          README_FILE="./README.md"
          # Build the new content for the latest 3 posts
          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 }}"

          # Replace the placeholder section using a different delimiter (|)
          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
Enter fullscreen mode Exit fullscreen mode

And in your README:

<!-- ARTICLES_START -->
<!-- ARTICLES_END -->
Enter fullscreen mode Exit fullscreen mode

GitHub Actions replaces everything between those two markers every time it runs.

Your profile stays updated. You don’t touch anything.


What Else Can You Automate With GitHub Actions?

Once you get comfortable with this, you’ll realize GitHub Actions can automate pretty much anything you can script. Here are some actually useful examples:


1. Automatically Add Your Latest YouTube Videos

If you upload tutorials or dev content, this keeps your profile fresh.

- name: Fetch YouTube videos
  run: |
    curl -s "https://www.googleapis.com/youtube/v3/search?key=$YT_API_KEY&channelId=$CHANNEL_ID&part=snippet&order=date&maxResults=5" > videos.json
Enter fullscreen mode Exit fullscreen mode

2. Auto-Update GitHub Stats or Badges

You can show live data:

  • follower count
  • stars
  • views
  • repo metrics
- run: curl -s https://api.github.com/users/YOUR_USER | jq '.followers'
Enter fullscreen mode Exit fullscreen mode

You can then embed that into badges or markdown.


3. Use GitHub Actions as a Free Cron Server

Run scheduled tasks without having any server.

on:
  schedule:
    - cron: "0 */6 * * *"  # Every 6 hours
Enter fullscreen mode Exit fullscreen mode

Good for:

  • cleaning old branches
  • updating analytics
  • regenerating documentation
  • syncing data

4. Create Your Own Personal Automation Bots

This part is way more fun than it sounds.

Examples:

  • get a Telegram/Discord ping when someone stars your repo
  • generate daily GitHub activity summaries
  • sync posts from X/Twitter or LinkedIn
  • rebuild your portfolio site every night
  • generate OG images
  • track metrics for projects

If you can script it, GitHub Actions can run it for free.


A Simple Automation Template You Can Reuse

name: My Automation

on:
  schedule:
    - cron: "0 0 * * *"
  workflow_dispatch:

jobs:
  run-script:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: python3 script.py
Enter fullscreen mode Exit fullscreen mode

Drop your logic into script.py and you’re done.


If you’ve been meaning to automate your own workflows or make your profile more dynamic, this is a great place to start. Try it, break it, tweak it, and make it your own hand✌️.

Top comments (0)