Adding Profile README Stats to Your Github Profile README

Rishi Chitnis - Aug 3 - - Dev Community

Have You ever looked at a Github Profile and saw Github Profile README Stats on it?

Image description

Well I'm going to walk you through the Steps of How you can have it also.

Step 1: You Will Need a Github Token:

You will need a Github Personal Access Token with the Following scops

repo and read:user

Image description

Image description

Step 2: You will need to add it to Your Repository's Secrets

You will need to go to your Repo's Settings, Click on Secrets and Variables and then Click on New Secret and Name it Anything you want like USER_TOKEN and add the Personal Access Token from the Previous Step.

Step 3: Create a Template file:

You will Need a Template file for this to work.

Add the Following code:

Joined Github **{{ ACCOUNT_AGE }}** years ago.

Since then I pushed **{{ COMMITS }}** commits, opened **{{ ISSUES }}** issues, submitted **{{ PULL_REQUESTS }}** pull requests, received **{{ STARS }}** stars across **{{ REPOSITORIES }}** personal projects and contributed to **{{ REPOSITORIES_CONTRIBUTED_TO }}** public repositories.

Most used languages across my projects:

{{ LANGUAGE_TEMPLATE_START }}
![{{LANGUAGE_NAME}}](https://img.shields.io/static/v1?style=flat-square&label=%E2%A0%80&color=555&labelColor={{LANGUAGE_COLOR:uri}}&message={{LANGUAGE_NAME:uri}}%EF%B8%B1{{LANGUAGE_PERCENT:uri}}%25)
{{ LANGUAGE_TEMPLATE_END }}

<p align="right"><sub>Generated using <a href="https://github.com/marketplace/actions/profile-readme-stats">teoxoy/profile-readme-stats</a></sub></p>
Enter fullscreen mode Exit fullscreen mode

Step 4: Create The Github Action:

Go to the Actions tab, Click on set up new workflow yourself, and in the .github/workflows directory name your file stats.yml and add the following code:

on:
  workflow_dispatch:
  schedule:
    - cron: '0 */6 * * *' # every 6 hours
  push:
    branches:
      - master
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: Generate README.md
      uses: teoxoy/profile-readme-stats@v3
      with:
        token: ${{ secrets.USER_TOKEN }}
    - name: Update README.md
      run: |
        if [[ "$(git status --porcelain)" != "" ]]; then
        git config user.name github-actions[bot]
        git config user.email 41898282+github-actions[bot]@users.noreply.github.com
        git add .
        git commit -m "Update README"
        git push
       fi
Enter fullscreen mode Exit fullscreen mode

Step 5: Run The Workflow

You should get the following output when you run the workflow, if you don't please feel free to look at My Profile:

Image description

And Boom, Your Profile Stats will automatcally get added every few hours.

See you next time

Bye

. . .
Terabox Video Player