valery1707 / badge-readme

Add badges in your Readme

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

alt text

badge-readme

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

Prep Work

  1. You need to update the markdown file(.md) with 2 comments. You can refer here for updating it.

  2. You can follow either of the Two Examples according to your needs to get started with.

Update your Readme

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.

Profile Repository

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.

  • Create a new file named 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@master
  1. Add a comment to your README.md like this:
<!--START_SECTION:badges-->
<!--END_SECTION:badges-->
  1. But default, the script will use the same username from github, but will can change it, and some others variables:
Option Default Value Description Required
GH_TOKEN - GitHub access token with Repo scope 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

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.

  1. Create a new Secret. Name: <VAR>, Value

  2. Go to Workflows menu (mentioned in step 1), click Update badges, click Run workflow.

  3. Go to your profile page. you will be able to see it.

Other Repository (not Profile)

You'll need a GitHub API Token with repo scope from here if you're running the action not in your Profile Repository

  • You can use this example to work it out

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@master
          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

Tests

Running Tests

To run tests simply execute the following in the folder tests. (need docker and docker-compose installed):

docker-compose build && docker-compose up

About

Add badges in your Readme

License:MIT License


Languages

Language:HTML 52.6%Language:Python 46.7%Language:Dockerfile 0.5%Language:Shell 0.2%