You might have seen people’s github readme profile which contains links to their blogs be it to medium or hashnode or dev.Now in this post i will be trying to explain to you how you can add them in your github profile readme.
Now there are two ways by which you can add the link to your blog First way is you manually update your profile readme every time you add a new blog,but since we are software engineers we won’t be doing so much manual work everytime. So what we will be doing is we will be writing a workflow once which will automatically update your readme file with your latest blog.
Note:-This post might be a bit heavy for beginners who are not very much familiar Git & Github but with a little extra effort you will be able to add this feature.
Now Let’s begin with the steps you need to perform:- I am assuming that you already have a Github account and a profile readme and if you don't have one search the internet for how to create one.
1.Create a .yaml file where the code to run the workflow will be written and name it whatever you want but i named it after the platform on which i write blogs(hashnode) After you have done the above copy the following code in the .yaml file-
name: Latest Hashnode blog post workflow
on:
schedule:
# Runs every day
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
update-readme-with-blog:
name: Update repo README with latest blog posts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gautamkrishnar/blog-post-workflow@master
with:
comment_tag_name: "HASHNODE"
feed_list: "https://harshcool.hashnode.dev/rss.xml"
commit_message: "Update hashnode.com blog posts"
gh_token: ${{ secrets.GITHUB_TOKEN }}
Now if you are a Hashnode blogger all you have to do is edit the feed_list with your RSS URL. To get the RSS URL just add "/rss.xml" after your blogs url. Note:-The given method is for hashnode, for other platforms you have to perform the above according to that platform.
2.Once you have your workflow running in place, the next step is to update your github readme where we are basically giving a place to the workflow as to where it has to show the result. Mention the following in your github readme-
# Blog Posts
<!-- HASHNODE:START -->
<!-- HASHNODE:END -->
Note:-The part before START
and END
should be the same as written in comment_tag_name
. Give this section a heading(in this case) Blog Posts.
And that was it, this was how you can automatically update your blogs to your github readme. You are most welcome to post the screenshot of the blog posts section in the comments of this blog or on Linkedin. Thanks for reading till here!