# Automatically display your latest posts on your GitHub Profile README

By Bobby Iliev, 2021-10-21. https://bobbyiliev.com/post/automatically-display-your-latest-posts-on-your-github-profile-readme/

# Introduction

By creating a repository with the same name as your GitHub username (eg. `bobbyiliev/bobbyiliev`) you actually create a special repository. Its README.md will appear on your public profile.

In this post I will show you how to automatically display your latest posts on your GitHub Profile README.md file like this:

![](https://imgur.com/d6LPDZw.png)

We will be using a GitHub action provided by  [Gautam krishna R](https://github.com/gautamkrishnar) called `blog-post-workflow`.

Let's get started!

# Prerequisits

Before you get started you would need the following:

 * A GitHub account and a GitHub public profile repository. If you do not have one yet, you can follow the steps on how to create it here: [Create a GitHub Profile README.md with widgets](https://devdojo.com/kritika-pattalam/create-a-github-profile-readmemd-with-widgets)
 * You would also need a blog with an RSS feed. If you already have a DevDojo account or a DEV account you should be all set!

# Cloning your repository

In order to set that you we will be using GitHub actions in order to automate the process.

The first thing that you would need to do is to clone your repository locally. To do so, visit your profile repo, click on the `Code` button and copy the link:

![](https://imgur.com/6wtZ0ys.png)

Then head over to your Git terminal and clone the repository:

```
git clone https://github.com/bobbyiliev/bobbyiliev.git
```

After that `cd` into the cloned repo:

```
cd bobbyiliev
```

> Make sure to change `bobbyiliev` with your actual username

# GitHub Actions

Once we have the project cloned locally, we need to create a `.github` folder and a `workflows` folder inside of it, we can use the `mkdir` command to do so:

```
mkdir -p .github/workflows
```

Once the `.github/workflows`, create a `.yaml` file with the name of the website that you will be using to import your posts from. For example, I will do this with DevDojo, so the name of the file would be `devdojo.yaml`:

```
touch .github/workflows/devdojo.yaml
```

With your favourite text editor, open the file and add the following content:

```
name: Latest DevDojo blog post workflow
on:
  schedule:
    # Runs every day
    - cron: '0 0 * * *'
  workflow_dispatch:

jobs:
  update-readme-with-blog:
    name: Update this repo's README with latest blog posts
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: gautamkrishnar/blog-post-workflow@master
        with:
          comment_tag_name: "DEVDOJO"
          feed_list: "https://devdojo.com/feed/bobbyiliev"
          commit_message: "Update devdojo.com blog posts"
          gh_token: ${{ secrets.GITHUB_TOKEN }}
```

> Important: you need to change the `feed_list` value with the URL to your RSS feed.

In my case I am using DevDojo, so my RSS feed is `https://devdojo.com/feed/bobbyiliev`. For Dev.to it would be `https://dev.to/feed/bobbyiliev` and for other providers it might be different.

As you can see under the steps section we are using a GitHub action provided by  [Gautam krishna R](https://github.com/gautamkrishnar) called `blog-post-workflow`. 

The `cron: '0 0 * * *'` specifies that the action will run every day at midnight.

# Update your README.md file

Once you have the GitHub workflow in place, you need to also update your `README.md` file and add the following in the section where you want your posts to be displayed at:

```
# 📖 Latest Blog posts
<!-- DEVDOJO:START -->
<!-- DEVDOJO:END -->
```

The part before the `START` and `END` keywords needs to match exactly with the `comment_tag_name` value from the YAML file above.

Once you make the changes, save the file, commit it and push the changes to GitHub:

 * Stage the files:
```
git add .
```

 * Commit your changes:

```
git commit -m "Add DevDojo blog-post-workflow"
```

 * Push your changes to GitHub:

```
git push origin main
```

With that your README.md profile will be updated every day at midnight.

To manually execute the workflow, go to Actions -> click on the Workflow -> and from the dropdown choose `Run Workflow`:

![](https://imgur.com/ejLnivh.png)

This will take a few seconds to run and it will update your README.md file with your latest posts!

As an example you could take a look at my workflows here:

[GitHub Workflows Example](https://github.com/bobbyiliev/bobbyiliev/tree/main/.github/workflows)

# Conclusion

If you like this GitHub action, make sure to star it on GitHub here:

[Blog post workflow](https://github.com/gautamkrishnar/blog-post-workflow)

Hope that you find this useful! If you want to learn more about Git and GitHub check out this free eBook here:

[💡 Introduction to Git and GitHub](https://github.com/bobbyiliev/introduction-to-git-and-github-ebook)
