Add badges only from Credly (for now), in your Readme.
Attention: the data access is public, but it is the individual responsibility of whoever shares the reported data
You need to update the markdown file(.md) with 2 comments. You can refer here for updating it.
You can follow either of the Two Examples according to your needs to get started with.
Add a comment to your README.md
like this:
<!--START_SECTION:badges-->
<!--END_SECTION:badges-->
These lines will be our entry-points for the dev metrics.
If you're executing the workflow on your Profile Repository (<username>/<username>
)
You wouldn't need an GitHub Access Token since GitHub Actions already makes one for you.
update-badges.yml
with the following contents inside the workflows folder:name: Update badges
on:
schedule:
# Runs at 0am UTC every day
- cron: "0 0 * * *"
jobs:
update-readme:
name: Update Readme with badges
runs-on: ubuntu-latest
steps:
- name: Badges - Readme
uses: pemtajo/badge-readme@main
README.md
like this:<!--START_SECTION:badges-->
<!--END_SECTION:badges-->
Option | Default Value | Description | Required |
---|---|---|---|
GH_TOKEN | - | GitHub access token with Repo scope | Yes |
GH_API_URL | https://api.github.com |
GitHub API (can be enterprise API) | No |
REPOSITORY | <username>/<username> |
Your GitHub repository | No |
CREDLY_USER | <username> |
User name used in Credly | No |
CREDLY_SORT | RECENT |
The sort type for return credly badges [RECENT/POPULAR] | No |
COMMIT_MESSAGE | Updated README with new badges |
Add a commit message of your choice | No |
BADGE_SIZE | 110 |
Defines the badge dimension. | No |
NUMBER_LAST_BADGES | 0 |
the number of the last badges that need to show - (0 to not set limit) | No |
Go to your repo secrets by hitting Settings => Secrets
tab in your profile repo. You can also enter the url https://github.com/USERNAME/USERNAME/settings/secrets . Please replace the USERNAME
with your own username.
Create a new Secret
. Name
: <VAR>
, Value
Go to Workflows menu (mentioned in step 1), click Update badges
, click Run workflow
.
Go to your profile page. you will be able to see it.
You'll need a GitHub API Token with repo
scope from here if you're running the action not in your Profile Repository
If you're executing the workflow on another repo other than <username>/<username>
You'll need to get a GitHub Access Token with a repo
scope and save it in the Repo Secrets GH_TOKEN = <Your GitHub Access Token>
Here is Sample Workflow File for running it:
name: Update badges
on:
schedule:
# Runs at 2am UTC
- cron: "0 2 * * *"
jobs:
update-readme:
name: Update Readme with badges
runs-on: ubuntu-latest
steps:
- name: Badges - Readme
uses: pemtajo/badge-readme@main
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
REPOSITORY: <username>/<username> # optional, By default, it will automatically use the repository who's executing the workflow.
COMMIT_MESSAGE: "My commit message to update badges" # optional
CREDLY_USER: <username_credly> # optional, but default will use the same from github
CREDLY_SORT: RECENT or POPULAR # optional, this is the two forms from credly sort, more popular or recent first, by default use RECENT
BADGE_SIZE: the resolution to the badges images # optional, 110x110 default
NUMBER_LAST_BADGES: the maximum last badges to show # optional, will show the 48 in the first page
Just run locally
python3 -m unittest discover -v -s tests
Or if prefere using docker, execute the following in the folder tests
. (need docker
and docker-compose
installed):
docker-compose build && docker-compose up