Skip to content
Latchkey

How to Create a Custom Badge from a Gist

schneegans/dynamic-badges-action writes shields endpoint JSON into a gist from CI, giving you a badge whose value you control from a workflow.

Create a gist to hold the badge JSON, generate a token with gist scope, then have schneegans/dynamic-badges-action write the label, message, and color on each run. Point the shields endpoint route at the gist raw URL.

Steps

  • Create a gist and note its ID; add a GIST_SECRET token with gist scope.
  • In CI, run schneegans/dynamic-badges-action with label, message, and color.
  • Reference the gist via the shields endpoint route in your README.

Workflow

.github/workflows/ci.yml
      - uses: schneegans/dynamic-badges-action@v1.7.0
        with:
          auth: ${{ secrets.GIST_SECRET }}
          gistID: 8e3f1c0a2b4d
          filename: widget-benchmark.json
          label: benchmark
          message: 1.8k ops/s
          color: blue

README markdown

README.md
![Benchmark](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/acme/8e3f1c0a2b4d/raw/widget-benchmark.json)

Gotchas

  • The token needs the gist scope; a repo-scoped token cannot write the gist.
  • shields caches the gist; use the raw URL without a commit SHA so it always reads the latest.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →