docs: self-host the star history chart from real stargazer data - #1628
docs: self-host the star history chart from real stargazer data#1628FenjuFu wants to merge 4 commits into
Conversation
GitHub restricted the stargazer-timestamp API to repository admins/collaborators (2026-06-30), so the embedded api.star-history.com chart now renders an error image for this repo. Replace it with a self-hosted SVG generated from the repository's real stargazer history, committed at docs/star-history.svg and referenced from the English, Chinese, and Japanese READMEs via repo-relative paths. The chart stays under the project's own control (no third-party image host) and renders correctly again. The SVG is a point-in-time snapshot and can be refreshed periodically by a scheduled workflow if desired. Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
Add a scheduled workflow (monthly + manual dispatch) that regenerates docs/star-history.svg from the repository's real stargazer history and commits it only when it changes. The generator uses Node built-ins only and fails closed if the token cannot read dated stars, so a permission problem never commits a broken chart. Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
lyj715824
left a comment
There was a problem hiding this comment.
审查结论:Request changes
这个 PR 的目标是把 README 中的 api.star-history.com 外链替换为仓库内的 docs/star-history.svg,并通过每月 GitHub Actions 重新生成图表。方向可以理解,但当前版本有几处会让“自动刷新/文档发布”链路失效的问题:
-
VitePress 构建会直接失败(P1)
docs/README.md:126使用了裸路径star-history.svg。我在 PR head 的 clean worktree 执行cd docs && npm install && DOCS_BASE=/astron-agent npm run docs:build,得到:
Rollup failed to resolve import "star-history.svg" from "docs/README.md"。这里应使用./star-history.svg。仓库的deploy-pages.yml会在docs/**变更时执行同一个构建,因此合并后文档站发布会被阻断。 -
PAT fallback 没有覆盖 git push(P1)
.github/workflows/star-history.yml:19的 checkout 使用默认github.token,并持久化了 git 凭据;:28的STAR_HISTORY_TOKEN只传给 Node 脚本的 API 请求,:40的裸git push仍会使用 checkout 写入的GITHUB_TOKEN。因此即使配置 PAT 解决了 stargazer API 读取,推送仍可能被当前 main 分支保护规则拒绝。若要直推,需要让 checkout/push 使用同一个具备相应权限的 PAT/App token;更稳妥的是创建 PR。 -
即使 push 成功,Pages 也不会因该 push 自动重建(P1)
GitHub 不会为由GITHUB_TOKEN触发的push再启动其他 workflow,而deploy-pages.yml只监听push(main/master, docs/**)。所以月度提交可能更新仓库文件,却不会更新文档站。需要使用 PAT/App token 推送,或显式 dispatch Pages workflow。 -
默认 token 的 stargazer 读取能力需要实际验证(P1)
GitHub 已对 stargazers 列表接口实施 admin/collaborator 限制。PR 中假设 repo-scopedGITHUB_TOKEN一定能读取带starred_at的列表,但这个新 workflow 没有在 PR CI 中运行,也没有提供实测证据;在同一政策下已有 Actions installation token 返回 403、PAT 返回 200 的案例。没有STAR_HISTORY_TOKEN时,当前脚本很可能每月失败并保留旧图。 -
生成的并不是稳定的历史累计曲线(P1/P2)
.github/scripts/gen-star-history.mjs:82-95用当前仍在 star 的用户列表序号作为历史累计值。用户取消 star 后会从列表消失,下一次重生成会把过去所有点整体下移;重新 star 也会改变时间。这样会回写历史,不能称为真实 cumulative star history。建议保存每月的stargazers_count快照并基于快照绘图,或明确文案这是当前 stargazer 的时间分布近似。
建议先修正 ./star-history.svg 并加入 docs build 检查;自动刷新部分在明确 token、分支保护、Pages 触发和历史数据模型后再合入。
…ar-history Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
|
Addressed all five review points in e2948e9 (after merging current main):
Validation: Operational note: the |
|
CI follow-up: 31 checks completed successfully (including the project matrix, CodeQL, DCO, and CLA). The sole red job is |
Summary
The Star History chart embedded in the READMEs currently renders an error image, not a chart. As of 2026-06-30 GitHub restricted the stargazer-timestamp API to a repository's admins/collaborators, so
api.star-history.comcan no longer read this repo's star dates and returns a "GitHub restricted access to star data" placeholder.This PR fixes the chart by self-hosting it instead of depending on an external service:
docs/star-history.svg, generated from this repository's real stargazer history (cumulative stars over time, 8,963★ at time of writing).docs/star-history.svg,star-history.svg,../star-history.svgrespectively) so each renders correctly from its own location.Why self-host rather than swap to another chart service
Keeping the image under the project's own control avoids handing README rendering to a third-party host the maintainers haven't vetted — the SVG is plain, versioned, and served from this repo. It also renders in contexts where GitHub's image proxy doesn't apply (mirrors, package pages, IDEs).
Notes
GITHUB_TOKENin Actions is allowed to do).<img src>lines changed in the READMEs; no other content (including theosai-verifymarker) was touched.---Update: now self-refreshing
This PR also adds
.github/workflows/star-history.yml(monthly + manualworkflow_dispatch) and.github/scripts/gen-star-history.mjs, so the chart stays current without manual work:GITHUB_TOKEN. It fails closed — if the token can't read dated stars, it errors and leaves the committed SVG untouched, so a permission problem never commits a broken chart.github-actions[bot].STAR_HISTORY_TOKENPAT secret (the workflow already prefers it when present). Happy to switch it to a PR-opening flow instead if you'd rather review each refresh.