Skip to content

Instantly share code, notes, and snippets.

@Realiserad
Last active December 10, 2025 00:04
Show Gist options
  • Select an option

  • Save Realiserad/d3ec7fdeecc35aeeb315b4efba493326 to your computer and use it in GitHub Desktop.

Select an option

Save Realiserad/d3ec7fdeecc35aeeb315b4efba493326 to your computer and use it in GitHub Desktop.
Badge JSONs for the shields.io endpoint badge API, updated using GitHub Actions

🤔 Want to know what this is about?

This gist is used to store JSON files for the shields.io endpoint badge API.

I use it to keep track of how much time I have spent on projects. The actual data is generated by CI. Here is an example of a GitHub Actions workflow for updating these files:

name: Badges
on:
  push:
    branches:
    - main
jobs:
  update-badge:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Write badge JSON
        run: |
          sudo apt install jo
          jo -p \
            "schemaVersion=1" \
            "label=Example label" \
            "message=Example message" > badge.json
      - name: Store result
        uses: realiserad/actions-deploy-gist@main
        with:
          token: ${{ secrets.TOKEN }}
          gist_id: gist_id
          file_path: badge.json

${{ secrets.TOKEN }} references a PAT with access to gists. gist_id is the ID of the gist as shown in the browser URL.

{
"schemaVersion": 1,
"label": "⏳ Time spent",
"message": "543 hours",
"color": "blue",
"style": "for-the-badge"
}
{
"schemaVersion": 1,
"label": "😍 Popularity",
"message": "155 recent visits",
"color": "red",
"style": "for-the-badge"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment