How I Built A Self-Updating README On My Github Profile

Search for a command to run...

No comments yet. Be the first to comment.
I'm a big fan of a table of contents (ToC) on the side of a blog post page, especially if it is a long article. It helps me gauge the article's length and allows me to navigate between the sections quickly. In this article, I will show you how to cre...

This year I launched a free eBook with 27 helpful tips for Vue developers for subscribers of my weekly Vue newsletter. For marketing purposes, I showed a popup on the landing page of my portfolio page each time a user visited my site. I was aware tha...

My portfolio website is built with Nuxt 3 and Nuxt Content v2. An RSS feed with my latest five blog posts is available here. In this article, you'll learn how to add an RSS feed to your Nuxt website. Setup First, let's create a new Nuxt 3 project. As...

title: How to Create a Custom Code Block With Nuxt Content v2 published: true date: tags: nuxt, vue, nuxtjs, vuejs, webdev canonical_url: https://www.mokkapps.de/blog/how-to-create-a-custom-code-block-with-nuxt-content-v2/ cover_image: https://dev-t...

Code blocks are essential for blogs about software development. In this article, I want to show you how can define a custom code block component in Nuxt Content v2 with the following features: Custom styling for code blocks inside Markdown files Sho...

GitHub profile README
On Hacker News I discovered the article Building a self-updating profile README for GitHub. I was very fascinated about this new GitHub feature and wanted to build something similar for my GitHub profile.
GitHub profile READMEs are a new feature that allows users to have the content of a README markdown file rendered at the profile page.
To use this feature you just need to create a new repository that has the same name as your GitHub account. Mine is located at github.com/mokkapps/mokkapps.This repository needs to be public and initialized with a README:

Now you will see a new section at the top of your profile page which renders the content of this new README file:

In my example, I am showing five links to the latest blog posts on my website and the latest tweet I published on Twitter. This information is automatically updated and I want to show you how I implemented this functionality.
All the magic is happening in a GitHub Action defined in build.yml. This action runs on every Git push, every 32 minutes past the hour (configured via a cron schedule) or by manually clicking a button in the GitHub Action UI (by using workflow_dispatch event).
The workflow performs these actions:
Fetches the latest tweet from my Twitter account using the Twitter API, renders it to a PNG using headless Chrome (from an R script) and saves it as PNG which is then embedded in the README (taken from zhiiiyang).
Runs a JavaScript script which fetches the five latest blog posts from my RSS feed and generates the final README.md (inspired by simonw)
Commits and pushes the changes to the master branch of this repo
The JS script is quite simple and has only ~50 lines of code.
The GitHub profile READMEs are a cool feature and by using GitHub Actions it can help us to provide up-to-date information for profile visitors.
But most importantly I had a lot of fun building it and this is more important than everything else.

Originally published at https://www.mokkapps.de.