I recently came across a very neat trick to spice up your GitHub user profile page. If you look at my GitHub user page, you'll see that it has some extra info about me as well as my latest blog posts. You can set this up yourself as well.
We'll be using the blog-post-workflow GitHub Action by Gautam krishna R to accomplish this.
The first thing you need to do is to create a repository named after your username. In my case, this was creating the following repository:
https://github.com/pieterclaerhout/pieterclaerhout
As soon as you name the repository the same as your username, GitHub will tell you that this is a "special" repository 🙀.
Once you created the repository, you can add a README.md
file which contains the contents shown on your user profile page. To get the latest posts in there, we need two extra things: a GitHub action and the RSS / Atom feed for our blog posts.
Let's start with adding the markup to our README.md
file to indicate where the latest posts should show up (please note the special placeholders):
1# 📩 Latest Blog Posts // You can name it whatever you want.
2<!-- BLOG-POST-LIST:START -->
3<!-- BLOG-POST-LIST:END -->
Once you committed this, we can setup a GitHub action which updates the README.md
on a regular basis. To set it up, create a file called .github/workflows/latest_posts.yml
in the same repository. Then put in the following content in that file:
.github/workflows/latest_posts.yml
1name: Latest posts workflow
2on:
3 schedule:
4 - cron: '0 * * * *'
5 workflow_dispatch:
6jobs:
7 update-readme-with-blog:
8 name: Update this repo's README with latest blog posts
9 runs-on: ubuntu-latest
10 steps:
11 - uses: actions/checkout@v2
12 - uses: gautamkrishnar/blog-post-workflow@master
13 with:
14 # Replace this URL with your rss feed URL/s
15 feed_list: "https://www.yellowduck.be/index.xml"
16 max_post_count: 10
17 template: "- `$date` | [$title]($url) $newline"
18 date_format: yyyy-mm-dd
19 tag_post_pre_newline: true
Commit the code, go to the Actions panel in your repository, select the workflow and run it manually. This will let the action do it's work and the posts should appear in the README.md
file now. As the action is setup with a cron
trigger as well, it will run every hour.
In my action, I've customized the action options slightly:
feed_list
: the link to the RSS / Atom feedmax_post_count
: the maximum number of posts to showtemplate
: a custom template for each blog post entry (I wanted the date to be included)date_format
: to customize how the date will show uptag_post_pre_newline
: Allows you to insert a newline before the closing tag and after the opening tag when using the template option if needed, for better formatting
If you want to learn more about GitHub actions, have a look at the official documentation.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.