mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 03:01:21 +02:00
ci(repo-stats): chart container pulls from ghcr.io alongside clones/stars
GHCR exposes total + 30-day daily-pull counts only in the package page
HTML (no REST or GraphQL endpoint). jgehrcke/github-repo-stats has no
notion of container metrics, so post-process the report after it runs.
New: .github/scripts/ghcr_inject.py
- Scrapes Total downloads (exact integer from title="N", not the K-rounded
display) and the 30-day sparkline (rect data-merge-count, data-date).
- Merges per-day rows into maziggy/bambuddy/ghcr-pulls.csv on gh-pages.
Fresh window overwrites overlapping dates, so GitHub's late revisions
to the last 30 days self-correct; days older than 30 stay frozen at
whatever was captured while still in-window.
- Patches latest-report/report.html: adds a TOC entry, a Container
pulls (ghcr.io) section at the top, and a Vega-Lite line+point chart
whose theme/config is cloned from the existing Total clones chart so
it inherits the report's look-and-feel.
- Bracketed by HTML-comment markers so re-runs replace rather than
stack (jgehrcke regenerates report.html every tick; we re-inject).
- Hard-fails if either scrape pattern stops matching — silent fallbacks
would let the chart freeze without notice.
Workflow: after run-ghrs, checkout source + gh-pages, run the injector,
commit only if the diff is non-empty. Uses the existing contents: write
permission; no new secrets.
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
name: GitHub Repo Stats
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 23 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
repo-stats:
|
||||
name: repo-stats
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: run-ghrs
|
||||
uses: jgehrcke/github-repo-stats@v1.4.2
|
||||
with:
|
||||
repository: maziggy/bambuddy
|
||||
ghtoken: ${{ secrets.GHRS_GITHUB_API_TOKEN }}
|
||||
ghpagesprefix: https://maziggy.github.io/bambuddy
|
||||
|
||||
# Inject ghcr.io container-download stats (cumulative + 30-day
|
||||
# sparkline merged into a sidecar CSV so the chart grows beyond
|
||||
# the 30-day window GHCR exposes). Runs after jgehrcke regenerates
|
||||
# report.html on gh-pages.
|
||||
- name: checkout-source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: source
|
||||
|
||||
# jgehrcke/github-repo-stats commits to the `github-repo-stats`
|
||||
# branch by default (NOT gh-pages — Pages is configured to serve
|
||||
# from that branch). Direct git clone with the PAT surfaces real
|
||||
# git stderr if anything fails, unlike actions/checkout@v4 which
|
||||
# swallows errors as opaque "exit code 1".
|
||||
- name: checkout-data-branch
|
||||
env:
|
||||
GH_PAT: ${{ secrets.GHRS_GITHUB_API_TOKEN }}
|
||||
run: |
|
||||
git clone --branch github-repo-stats --depth 1 \
|
||||
"https://x-access-token:${GH_PAT}@github.com/${{ github.repository }}.git" \
|
||||
data
|
||||
cd data
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
- name: inject-ghcr-pulls
|
||||
run: |
|
||||
python3 source/.github/scripts/ghcr_inject.py \
|
||||
--report data/maziggy/bambuddy/latest-report/report.html \
|
||||
--csv data/maziggy/bambuddy/ghcr-pulls.csv \
|
||||
--owner maziggy \
|
||||
--pkg bambuddy
|
||||
|
||||
- name: commit-and-push
|
||||
working-directory: data
|
||||
run: |
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
echo "no changes — skipping commit"
|
||||
exit 0
|
||||
fi
|
||||
git add maziggy/bambuddy/latest-report/report.html \
|
||||
maziggy/bambuddy/ghcr-pulls.csv
|
||||
git commit -m "ghcr-pulls: refresh container downloads chart"
|
||||
git push
|
||||
Reference in New Issue
Block a user