We all know Github is a great platform to collaborate with people and contribute to open source projects. daily, we do perform some activities on GitHub like creating an issue, creating a pull request, code review and all other things.
These are the activities that get added to our contributions and we get a green square for each day with our contributions counts.
For Example, contribution count graph like this,
When we click on any box we will get activities of that day something like this.
Here you can see my activities of date 10th October 2021
, I created some commits and opened some issues.
Have you ever thought of showing your GitHub activities on your Profile Readme?
You will be thinking like is that even possible? yes, it is possible and today in this article, we will be discussing how to show our recent GitHub activities on our profile readme.
Let's get started.
We will be going to use Github Actions that will help us to create a workflow to show our recent activities on Profile readme.
before jumping into the setup let's first discuss what are GitHub actions and what they are used for.
What are GitHub actions?
GitHub actions are a set of events and workflow, whenever specified events happen to your GitHub repository it will run the associated workflow for it.
want to learn more about Github actions, you can get started from here
GitHub - Activity - Readme
GitHub - Activity - Readme is a Github action that will update your profile readme with recent GitHub activity.
It is created by James George you can check his profile here
to work with this action we will need to set up a workflow that will be running automatically to update the profile readme with recent activities.
Setting up workflow
we can easily set up this workflow in our profile repository to capture and update profile readme with recent activities.
Create the .github
folder in your profile repository if it does not exist.
> mkdir .github
Create the workflows
folder inside the .github
folder if it does not exist.
>mkdir .github/workflows
Create the {workflowname}.yml
file inside workflows
folder.
where you can replace workflow name with your workflow name. I will give the name update-readme.yml
.
> update-readme.yml
after creating a workflow file add this content to it.
name: Update README
on:
schedule:
- cron: "*/5 * * * *" # Runs every 5 minutes.
jobs:
build:
runs-on: ubuntu-latest
name: Update this repo's README with recent activity
steps:
- uses: actions/checkout@v2
- uses: jamesgeorge007/github-activity-readme@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
COMMIT_MSG: "Updated README with recent activity"
MAX_LINES: 10
Here we have three main components of the workflow
- name
- on
- jobs
Let's discuss them one by one
- name is the name of the workflow after workflow run If you see the actions tab in your repository you will get workflow runs like this.
- on is used for defining what action you want to run this workflow.
here we are running this workflow on schedule
using a cron job to run this workflow every 5 minutes automatically.
If you don't know much about cron syntax this may be helpful for you
The quick and simple editor for cron schedule expressions
- jobs is used for defining what to do when an event happens on our repository.
here we are defining only one job that is build which will commit on our repository with the message Update this repo's README with recent activity.
for jobs, we will need to define what environment it will be running and we are running this job on ubuntu
.
also, we will need to define what steps to use, something like this
- uses: actions/checkout@v2
- uses: jamesgeorge007/github-activity-readme@master
env
is used for automatic token authentication.
you don't need to worry about secrets.GITHUB_TOKEN
will automatically get referred from your GitHub account.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if you notice we are using the with
attribute for 2nd action that is jamesgeorge007/github-activity-readme@master
here we are providing 2 options COMMIT_MSG
and MAX_LINES
.
- COMMIT_MSG - Commit message used while committing to the repository.
- MAX_LINES - The most number of lines should populate in your readme file
Now, I hope we are clear with all the components of a workflow.
The Last step is to add this content to your profile README.md
file.
# Recent Activity :zap:
<!--START_SECTION:activity-->
<!--END_SECTION:activity-->
Think of it like a block that will get replaced by your recent activities.
For Example :
# Recent Activity :zap:
<!--START_SECTION:activity-->
1. π Merged PR [#2197](https://github.com/open-metadata/OpenMetadata/pull/2197) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
2. βοΈ Closed issue [#2040](https://github.com/open-metadata/OpenMetadata/issues/2040) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
3. βοΈ Closed issue [#2028](https://github.com/open-metadata/OpenMetadata/issues/2028) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
4. βοΈ Closed issue [#2156](https://github.com/open-metadata/OpenMetadata/issues/2156) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
5. π£ Commented on [#2156](https://github.com/open-metadata/OpenMetadata/issues/2156) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
6. π Merged PR [#2154](https://github.com/open-metadata/OpenMetadata/pull/2154) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
7. βοΈ Closed issue [#2087](https://github.com/open-metadata/OpenMetadata/issues/2087) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
8. βοΈ Opened issue [#2156](https://github.com/open-metadata/OpenMetadata/issues/2156) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
9. βοΈ Opened issue [#2147](https://github.com/open-metadata/OpenMetadata/issues/2147) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
10. βοΈ Closed issue [#1876](https://github.com/open-metadata/OpenMetadata/issues/1876) in [open-metadata/OpenMetadata](https://github.com/open-metadata/OpenMetadata)
<!--END_SECTION:activity-->
Example of my profile readme with recent activities
Summary
- we discussed what are github actions and why they are used for.
- we did set up the workflow to update our profile readme with recent activities.
Links
And thatβs it for this topic. Thank you for reading.
Top comments (2)
Hello. I'm one of the authors of github.com/Readme-Workflows/recent... .
The repository you mentioned is no longer maintained. We have created a new workflow which is more customizable. Have a look. Thanks.
Thanks for reading. surely will check it out.