Giter Club home page Giter Club logo

badge-readme's Introduction

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@main
  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 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.

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

Tests

Running Tests

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

badge-readme's People

Contributors

aress31 avatar dschunack avatar pemtajo avatar rikvik2006 avatar samtrion avatar valery1707 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.