Whenever I publish a blog post here on Dev Community, or achieve a new badge from Credly, I have to manually update my GitHub profile to display these updates. It's not the most exciting task and can be a drain on productivity.
There has to be a way to automate the boring stuffs, right? Isn’t that what developers do?
The answer is yes! This is where GitHub Actions comes in.
In this blog post, we will explore GitHub Actions automation solution to eliminate this repetitive process.
- What is GitHub Actions?
- Steps to auto-update Dev.to Blog Posts on GitHub Profile
- Steps to auto-update Credly Badges on GitHub
- Conclusion
What is GitHub Actions?
GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline.
GitHub Actions helps you automate processes in your GitHub repository using workflows. Workflows are configurable-automated processes that will run one or more jobs. Workflows are defined by a YAML file checked in to your repository and will run when triggered by an event in your repository, or they can be triggered manually, or at a defined schedule. Learn how to write GitHub Actions YAML files in the GitHub Tutorial.
Let's get into it.
The code used in this blog post can be found on my GitHub repository
Steps to auto-update Dev.to Blog Posts on GitHub Profile:
a.) Edit your special repository README file on GitHub <username>/<username>/README.md
. Add the following section to your README.md file:
---
## Latest Blog Posts
<!-- BLOG-POST-LIST:START -->
<!-- BLOG-POST-LIST:END -->
b.) On this special repository, create a folder named .github
and create workflows
folder inside if it doesn't already exist.
c.) Create a new file named blogpost-update.yml
inside this workflows directory. Copy and paste the below YAML code inside the file you just created:
name: Latest blog post workflow
on:
schedule: # Run workflow automatically
- cron: '0 * * * *' # Runs every hour, on the hour
workflow_dispatch: # Run workflow manually (without waiting for the cron to be called), through the Github Actions Workflow page directly
permissions:
contents: write # To write the generated contents to the readme
jobs:
update-readme-with-blog:
name: Update this repo README with latest blog posts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gautamkrishnar/blog-post-workflow@master
with:
feed_list: "https://dev.to/feed/<devto username>"
d.) Replace the feed_list URL with your own dev.to RSS feed.
e.) Save the changes and commit your code. You can either allow this workflow to run automatically, or you can manually trigger this workflow.
Here are some other popular blog sources you may want to automate:
Dev.to: https://dev.to/feed/username
Medium: https://medium.com/feed/@username
Hashnode: https://@username.hashnode.dev/rss.xml
WordPress: https://www.example.com/feed/
YouTube Channel Video: https://www.youtube.com/feeds/videos.xml?channel_id=channelId
Steps to auto-update Credly Badges on GitHub:
a.) Edit your special repository README file on GitHub //README.md.
b.) Add the following section to your README.md file:
---
## View my verified badges
<!--START_SECTION:badges-->
<!--END_SECTION:badges-->
c.) Create a GitHub workflow YAML file, badge-update.yml
. Copy the below code and paste it to the new workflow YAML file you created.
name: Update Credly Badges
on:
schedule:
# Runs at 2am UTC
- cron: "0 2 * * *"
workflow_dispatch: # Run workflow manually (without waiting for the cron to be called), through the Github Actions Workflow page directly
permissions:
contents: write # To write the generated contents to the readme
jobs:
update-readme:
name: Update Readme with badges
runs-on: ubuntu-latest
steps:
- name: Badges - Readme
uses: pemtajo/badge-readme@main
with:
CREDLY_USER: <credly username> # optional, but default will use the same from github
d.) Replace the with your own credly username.
e.) Save this change and commit your code. You can either allow this workflow to run automatically, or you can manually trigger it.
Here is how my GitHub Profile looks after running the workflows.
Conclusion
In this blog post, we introduced GitHub Actions, defined GitHub Actions workflows, dived into the steps to auto-update Dev.To Blog Posts on GitHub Profile and steps to auto-update Credly badges on GitHub Profile. GitHub Actions is a helpful tool to automate processes and save time on repetitive tasks.
Thanks for reading. Let me know if you found this helpful. You are welcome to follow me on LinkedIn and Twitter @Paschal_ik.
Top comments (5)
Thanks for this
Thanks for reading
Thanks for sharing this with us
You're welcome
Great write-up! We also have a bunch of articles on Github Actions in our Newsletter, check it out - packagemain.tech/p/github-actions-...