Skip to content

feat(ci): add total clone-count badge to the README#71

Open
ucekmez wants to merge 1 commit into
mainfrom
feat/clone-count-badge
Open

feat(ci): add total clone-count badge to the README#71
ucekmez wants to merge 1 commit into
mainfrom
feat/clone-count-badge

Conversation

@ucekmez

@ucekmez ucekmez commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a total git-clone count badge to the README, accumulated daily into a
public Gist (GitHub's traffic API only retains 14 days). Adapted from
MShawon/github-clone-count-badge.

"Total" = from first run onward. GitHub does not expose clones from before
setup, so the counter grows over time; it is not an all-time figure.

Hardened for this repo

Unlike the upstream recipe, this does not curl … | python3 remote code at
runtime:

  • accumulation script is vendored (.github/scripts/accumulate_clones.py, reviewed);
  • workflow runs with permissions: contents: read, pins the action, commits nothing back;
  • the PAT (SECRET_TOKEN) is used only for the traffic + gist API calls; the gist
    id is a public repo variable, not a secret.

Verification

  • accumulate_clones.py merge logic tested locally: first window 6+4 → 10;
    next day with an overlapping row + a new one → 15 (overlap overwritten, not
    double-counted).
  • Workflow YAML validates.

⚠️ Activation requires one-time setup (owner only)

The badge renders a __GIST_ID__ placeholder until configured. See
docs/ops/clone-count-badge.md:

  1. Create a public gist with clone.json = {"count":0,"uniques":0,"clones":[]}.
  2. Add a classic PAT (repo + gist) as the SECRET_TOKEN secret.
  3. Add Actions variable GIST_ID = the gist id.
  4. Replace __GIST_ID__ in the README badge URL with the gist id.
  5. Run the workflow once (Actions → "Clone count badge" → Run workflow).

🤖 Generated with Claude Code

Adds a daily job that accumulates git-clone counts into a public Gist and a
shields.io badge in the README. GitHub's traffic API only retains 14 days of
clone data, so the workflow merges each window into a running total.

Adapted from MShawon/github-clone-count-badge, hardened for this repo:
  - the accumulation script is vendored (.github/scripts/accumulate_clones.py)
    rather than curl-piped into python3 at runtime (no unpinned remote code
    executes in CI);
  - the workflow runs with `permissions: contents: read`, pins the action, and
    commits nothing back to the repo (no CLONE.md / third-party push action);
  - the gist id is a repository variable (it is public) and the PAT lives in the
    `SECRET_TOKEN` secret, used only for the traffic + gist API calls.

The total accumulates from the first run onward; historical clones are not
exposed by GitHub. One-time setup and rotation are documented in
docs/ops/clone-count-badge.md. The README badge URL carries a `__GIST_ID__`
placeholder to be replaced with the gist id during setup.

Signed-off-by: Ugur Cekmez <ucekmez@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant