Skip to content

Clone any website with one command using AI coding agents

fix: count the README token badge in CI (#125)

JCodesMoreee3f5a2f31fd
diff --git a/.github/workflows/token-badge.yml b/.github/workflows/token-badge.yml
new file mode 100644
index 00000000..759e1e05
--- /dev/null
+++ b/.github/workflows/token-badge.yml
@@ -0,0 +1,71 @@
+name: Token badge
+
+on:
+ push:
+ branches:
+ - master
+ workflow_dispatch:
+
+concurrency:
+ group: token-badge
+ cancel-in-progress: true
+
+jobs:
+ count:
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ outputs:
+ badge: ${{ steps.count.outputs.badge }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+ with:
+ path: repo
+ persist-credentials: false
+
+ - name: Checkout gittokens
+ uses: actions/checkout@v7
+ with:
+ repository: rsamf/gittokens
+ ref: 9081a2f2cc17055ab6a442ee74d8b35b2bc1ff7d
+ path: gittokens
+ persist-credentials: false
+
+ - name: Setup Python
+ uses: actions/setup-python@v7
+ with:
+ python-version: "3.12"
+
+ - name: Install counter
+ run: pip install --quiet gitingest==0.3.1 tiktoken httpx
+
+ - name: Count tokens
+ id: count
+ env:
+ COUNT_PATH: repo
+ DRY_RUN: "true"
+ run: echo "badge=$(python gittokens/action/count_and_publish.py | jq -c .)" >> "$GITHUB_OUTPUT"
+
+ publish:
+ needs: count
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ contents: write
+
+ steps:
+ - name: Publish badge JSON to the badges branch
+ env:
+ BADGE: ${{ needs.count.outputs.badge }}
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ test -n "$BADGE"
+ git init -q badge
+ cd badge
+ printf '%s\n' "$BADGE" > token-badge.json
+ git add token-badge.json
+ git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" commit -q -m "Update token badge"
+ git push --force "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:refs/heads/badges
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9419afc0..2dc2c3b5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+- Count the README token badge in CI so it reflects the current default branch instead of a stale hosted count.
+
## [0.6.1] - 2026-10-05
### Changed
diff --git a/README.md b/README.md
index 7f13ef59..4ed16fd4 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Give your AI coding agent a URL and watch it recreate the website as a clean Nex
[Quick Start](#quick-start) · [Watch Demo](#demo) · [Supported Platforms](#supported-platforms)
-<a href="https://github.com/JCodesMore/ai-website-cloner-template/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License" /></a> <a href="https://github.com/JCodesMore/ai-website-cloner-template"><img src="https://img.shields.io/github/stars/JCodesMore/ai-website-cloner-template?style=flat" alt="Stars" /></a> <img src="https://img.shields.io/endpoint?url=https://gittokens.rsamf.com/badge/JCodesMore/ai-website-cloner-template" alt="tokens" />
+<a href="https://github.com/JCodesMore/ai-website-cloner-template/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License" /></a> <a href="https://github.com/JCodesMore/ai-website-cloner-template"><img src="https://img.shields.io/github/stars/JCodesMore/ai-website-cloner-template?style=flat" alt="Stars" /></a> <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/JCodesMore/ai-website-cloner-template/badges/token-badge.json" alt="tokens" />
<a href="https://trendshift.io/repositories/24302?utm_source=repository-badge&amp;utm_medium=badge&amp;utm_campaign=badge-repository-24302" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/repositories/24302" alt="JCodesMore%2Fai-website-cloner-template | Trendshift" width="250" height="55" /></a> <a href="https://www.star-history.com/jcodesmore/ai-website-cloner-template/"><picture><source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/badge?repo=JCodesMore/ai-website-cloner-template&amp;theme=dark" /><source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/badge?repo=JCodesMore/ai-website-cloner-template" /><img alt="Star History Global Rank" src="https://api.star-history.com/badge?repo=JCodesMore/ai-website-cloner-template" width="216" height="55" /></picture></a>