Update your GitHub profile with your chess.com games with a GitHub Action
Leonardo Montini
Posted on July 27, 2022
When navigating through GitHub you may land on awesome profiles with "live" content being updated automatically, what kind of sorcery is this?
Let's start from the beginning!
Setup a personal profile
On top of the basic GitHub profile with pinned repos and the (very cool) contribution chart, you can fully customize the content in markdown basically by writing a README.md file, of your profile.
All you have to do is create a new repository with your username and put a README.md file in it.
In my case, my username is Balastrong so the repo will be Balastrong/Balastrong.
GitHub already notices that by adding this little badge in the home of your repo.
Bring it to life with GitHub Actions!
I'm sure you know the existence of GitHub Actions. Well, they can be used to edit files in your repository, right?
Now, the file you're going to edit is README.md and it will fetch some content from the internet, before formatting and putting it into your file.
Chess.com games!
Now that we have the combination profile + actions, we can make the magic!
All you need is to use this action: Chess.com Games & Stats [Marketplace], [Repository].
You can find the instruction there!
In short, you just need to two two basic steps:
1. Setup a placeholder in your README.md
You can control where the data will appear by putting this inside your file:
GitHub helps you setting up a new action, but anyway it's just adding a new file in .github/workflows in your repository and that's it.
The content is as simple as:
name:Chess Stats Actionon:schedule:-cron:'00***'# Runs at 00:00 UTC every dayworkflow_dispatch:jobs:update-readme:name:Update readme with your chess stats and gamesruns-on:ubuntu-lateststeps:-uses:actions/checkout@v3-uses:Balastrong/chess-stats-action@masterwith:CHESS_USERNAME:<Your chess.com Username>
Just replace <Your chess.com Username> and you're good to go!
With the current cron schedule it will run by itself ad midnight UTC, but thanks to workflow_dispatch you can also run the action manually at any time.
Since my goal was to get the last N games and I cannot know how many games an archive has, I decided to request the archives first, and then call them one by one until I get the desired amount of games (or I requested 5 archives, that's enough).
Aaand... it kind of works :)
Thanks for reading my post, I hope you find it interesting!
Feel free to follow me to get notified when new articles are out ;)
I'm a π-shaped Frontend Developer, Open Source maintainer and content creator. Awarded GitHub Star 🌟 (2023 and 2024) and Microsoft MVP 🔷 (2024) in Developer Tools and Web Development.
I enjoy constantly learning new skills and sharing knowledge with everyone around me. You can find my content on YouTube and leonardomontini.dev.