Automation using GitHub Action to add Blogs to GitHub Profile

Automation using GitHub Action to add Blogs to GitHub Profile

A hands-on guide to make your GitHub Profile standout!

Many years ago, a wise man once told me, "Why spend 5 minutes doing something when you could spend 5 hours failing to automate it?"

One of the secrets to productivity in life is AUTOMATION! As I plow through life I try to delegate anything repetitive to the automation so I can focus on things that are important in life

When it comes to software development my favourite continuous integration and continuous delivery tool is GitHub Actions.

Do you want to show your blogs on your GitHub Profile?

If yes, you're in the right place. By the end of this article, you'll have your latest articles listed on your GitHub profile README using Github Action Automation.

First of all lets understand:

What's GitHub Actions?

Events:

When you host your code on GitHub, there are certain events that can take place, such as when you push code in your main branch or someone makes a pull request to merge changes into your code or maybe opens up an issue. There is huge list of events that can happen to your repository.

Actions:

Now with an action you can trigger some code to run automatically when one of these events take place. In the background, GitHub will triggers and run the code to automate things like testing, deployment and so on.

Benefits of using GitHub Actions:

Along with the N number of benefits GitHub Actions offers, like seamless integration, flexibility, scalability, and cross-platform support, it is also very cost-effective.

Computing the same things on the cloud might cost money, but GitHub provides a very generous free tier for us that most people won't exceed.

🏃🏼Let's Get Started!

Prerequites:

  1. GitHub Account: https://github.com

  2. Basics of YAML

  3. Basics of Markdown (Markup Language)

We'll be using the blog-post-workflow GitHub Action created by Gautam krishna R.

🤔 How to use this GitHub Action?

  1. Visit your GitHub Profile README repository

     https://github.com/{USER-NAME}/{USER-NAME}
    

    Example: https://github.com/boradesanket13/boradesanket13

  2. Add the following section to your README.md file.

     # 📩 Latest Blog Posts
     <!-- BLOG-POST-LIST:START -->
     <!-- BLOG-POST-LIST:END -->
    
    • This # 📩 Latest Blog Posts is simple H1 heading in Markdown. You can write anything as per your choice.

    • <!-- BLOG-POST-LIST:START --> <!-- BLOG-POST-LIST:END --> marks the start and end of your blogs list.

  3. Create a folder .github in the root directory & within that directory create another folder named workflows.

     .github 
        └───workflows
    

    If you're struggling in creating a folder in the GitHub repository from a web app: To create a new folder in a repository click “create a new file.” Type your new folder’s name in the area where you would write the file name, and at the end of the file name type a “/” to initilize it as a folder. After this you can create a new file in the folder.

  4. Inside the workflows directory create a new YAML file named blog-post-workflow.yml. This is how your folder structure should look like:

.github 
   └───workflows
           blog-post-workflow.yml
  1. Add the following content in the blog-post-workflow.yml file
  1.  name: Latest blog post workflow
     on:
      schedule: # Run workflow automatically
        # This will make it run every hour
        - cron: '0 * * * *' 
       # Run workflow manually (without waiting for the cron to be called), through the Github Actions Workflow page directly
      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:
              # Replace this URL with your rss feed URL/s
              feed_list: "https://boradesanket13.hashnode.dev/rss.xml"
    

    Add your RSS Feed URL in place of my URL in the last line at feed_list

  2. Commit your code and wait for your actions to run automatically or here are the steps to trigger it manually:

    • Click on Actions

    • Then, click on Latest blog post workflow

    • Now, click on Run workflow to trigger the GitHub Action

NOTE: You can include the RSS feed URL from any popular blogging platform.
(See list of platforms)

That's it! We did it. 🎉

Now, you can view your GitHub Profile README, which now lists your latest published articles. 🎊

This is How it should look

Thanks, for reading it till the end.


That’s all for today! I hope you find this post useful. Feel free to share your questions, comments, and feedback. :)🚀

Portfolio | LinkedIn | GitHub | Twitter


Resources to Learn More:

References: