Skip to content

Action to add badges to your 42 project repo to quickly see your grade / bonus / correctors

Notifications You must be signed in to change notification settings

bauhaas/42project-badge-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

42project-badge-action

This action allows you to generates badges related to your 42 project for your README.md with shields.io.

Configuration

/!\ You don't have to repeat step 1 & 2 for each of your repo project. 3 & 4 are needed steps everytime /!\

  1. Head over to gist.github.com and create a new gist. You can name the file test.json, but this can be changed later as well. You will need the ID of the gist (this is the long alphanumerical part of its URL) later.
  2. Navigate to github.com/settings/tokens and create a new token with the gist scope.
  3. Go to the Secrets page of the settings of your repository and add this token as a new secret. You can give it any name, for example GIST_SECRET.
  4. Add something like the following to your workflow:
- name: 42 Project Badge
  uses: Korkrane/[email protected]
  with:
    login: <your-42-login>
    project: <your-42-project>
    auth: ${{ secrets.GIST_SECRET }}
    gistID: <gist-ID>

Required Input Parameters

Parameter Description
login Your 42 login
project A 42 project name
auth A secret token with the gist scope.
gistID The ID of the target gist. Something like 8f6459c2417de7534f64d98360dde866.

How Does It Work?

Whenever this action is executed, it creates 3 JSON objects based on the input parameters. This JSON object may look like this:

{
  "schemaVersion":1,
  "label":"grade",
  "message":"125 / 100",
  "color":"success",
  "style":"flat-square"
}

This JSON object is then uploaded as a file to a gist (click here for an example) and can be transformed to a badge like badge with the shields.io/endpoint. Here is the URL of this example badge:

https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Korkrane/e68282bd835f9dab85e2c6b9b5522143/raw/finished_grade.json

Once the action is executed, go to your gist. There should be 3 new file called : <your-42-project>_grade.json, <your-42-project>_bon.json, <your-42-project>_corr.json.

You can view the raw content of this file at https://gist.githubusercontent.com/<user>/<gist-ID>/raw/<filename>.json.

Embed the badge with:

![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/<user>/<gist-ID>/raw/<filename>.json)

Example usage

# .github/workflows/main.yml
name: 42-project-badge
on:

  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo content
        uses: actions/checkout@v3

      - name: 42 Project Badge
        uses: Korkrane/[email protected]
        with:
          login: bahhas
          project: dr-quine
          auth: ${{ secrets.GIST_SECRET }}
          gistID: e68282bd835f9dab85e2c6b9b5522143

Example badge display

Project you subscribed to but didn't finish yet :

badge badge badge

Valid project with bonus:

badge badge badge

Valid project without bonus:

badge badge badge

Failed project:

badge badge badge

About

Action to add badges to your 42 project repo to quickly see your grade / bonus / correctors

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages