This action allows you to generates badges related to your 42 project for your README.md with shields.io.
/!\ You don't have to repeat step 1 & 2 for each of your repo project. 3 & 4 are needed steps everytime /!\
- 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. - Navigate to github.com/settings/tokens and create a new token with the gist scope.
- 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
. - 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>
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 . |
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 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)
# .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
Project you subscribed to but didn't finish yet :
Valid project with bonus:
Valid project without bonus:
Failed project: