mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-09-01 16:18:09 +00:00
Loading demo/README.md was unusable — 65 themes × 15 SVGs = 975 images
in one page, and reloading made the tab lag for 10+ seconds. Restructure:
- demo/README.md shrinks to an index: one bullet per theme linking to
that theme's page. Zero images.
- demo/<theme>/README.md (new) embeds the 15 SVGs for that theme only,
grouped so the last-year / all-time variants sit side-by-side in HTML
tables. Readers compare LY vs AT without scrolling back and forth,
and fetch ~15 images instead of 975.
Per-theme page layout:
## At-a-glance profile · stats · streak (each full-width)
## Repos top-starred · repos-per-language
## Contributions heatmap · by-year, then
monthly shape: LY | AT (paired)
## When you commit hour-of-day: LY | AT
day-of-week: LY | AT
## What you commit language share: LY | AT
pair() and single() bash helpers skip missing SVGs so a future
partial-render doesn't emit dangling <img> tags.
129 lines
4.6 KiB
YAML
129 lines
4.6 KiB
YAML
name: Demo
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- "demo/**"
|
|
- "**.md"
|
|
- "LICENSE"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: demo
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
generate:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: "1.26"
|
|
cache: true
|
|
|
|
- name: Build ghstats
|
|
run: go build -trimpath -ldflags="-s -w" -o ghstats .
|
|
|
|
- name: Render every card for every theme
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GHSTATS_TOKEN }}
|
|
run: |
|
|
rm -rf demo
|
|
mkdir -p demo
|
|
./ghstats \
|
|
-user "${{ github.repository_owner }}" \
|
|
-themes all \
|
|
-tz Asia/Saigon \
|
|
-out demo
|
|
|
|
- name: Write demo READMEs (index + per-theme)
|
|
env:
|
|
OWNER: ${{ github.repository_owner }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
themes=$(./ghstats -list-themes)
|
|
|
|
# Lightweight index so readers don't have to load ~975 images at once.
|
|
{
|
|
echo "# ghstats demo gallery"
|
|
echo
|
|
echo "Every card rendered for [\`$OWNER\`](https://github.com/$OWNER) in every supported theme. Click a theme to open its gallery page — each page embeds 15 SVGs, so only the theme you're reviewing is fetched."
|
|
echo
|
|
echo "Auto-generated by [\`.github/workflows/demo.yml\`](../.github/workflows/demo.yml) on each push to \`main\`. Do not edit by hand."
|
|
echo
|
|
echo "## Themes"
|
|
echo
|
|
for theme in $themes; do
|
|
dir="demo/$theme"
|
|
[ -d "$dir" ] || continue
|
|
echo "- [\`$theme\`](./$theme/README.md)"
|
|
done
|
|
} > demo/README.md
|
|
|
|
# Per-theme page groups singletons at top, then compares last-year
|
|
# vs all-time variants side-by-side so the reader can eyeball the
|
|
# evolution of each metric without scrolling.
|
|
for theme in $themes; do
|
|
dir="demo/$theme"
|
|
[ -d "$dir" ] || continue
|
|
out="$dir/README.md"
|
|
pair() {
|
|
local heading="$1" left="$2" right="$3"
|
|
[ -f "$dir/$left.svg" ] && [ -f "$dir/$right.svg" ] || return
|
|
printf '### %s\n\n' "$heading"
|
|
printf '<table><tr><th>Last year</th><th>All time</th></tr><tr>\n'
|
|
printf '<td><img src="./%s.svg" alt="%s" /></td>\n' "$left" "$left"
|
|
printf '<td><img src="./%s.svg" alt="%s" /></td>\n' "$right" "$right"
|
|
printf '</tr></table>\n\n'
|
|
}
|
|
single() {
|
|
local heading="$1" name="$2"
|
|
[ -f "$dir/$name.svg" ] || return
|
|
printf '### %s\n\n\n\n' "$heading" "$name" "$name"
|
|
}
|
|
{
|
|
printf '# ghstats — %s\n\n' "$theme"
|
|
printf '[← back to index](../README.md)\n\n'
|
|
printf 'Rendered for [`%s`](https://github.com/%s). 15 SVGs below, ' "$OWNER" "$OWNER"
|
|
printf 'grouped so the last-year / all-time pairs sit next to each other.\n\n'
|
|
printf '## At-a-glance\n\n'
|
|
single "Profile" profile-details
|
|
single "Stats" stats
|
|
single "Streak" streak
|
|
|
|
printf '## Repos\n\n'
|
|
single "Top starred" top-starred-repos
|
|
single "Repos per language" repos-per-language
|
|
|
|
printf '## Contributions — time series\n\n'
|
|
single "Calendar heatmap (last year)" contributions-heatmap
|
|
single "By year (all time)" contributions-by-year
|
|
pair "Monthly shape" contributions contributions-all-time
|
|
|
|
printf '## When you commit\n\n'
|
|
pair "By hour of day" productive-time productive-time-all-time
|
|
pair "By day of week" productive-weekday productive-weekday-all-time
|
|
|
|
printf '## What you commit in\n\n'
|
|
pair "Byte-weighted language share" most-commit-language most-commit-language-all-time
|
|
} > "$out"
|
|
done
|
|
|
|
- name: Commit demo back to main
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add demo
|
|
if git diff --cached --quiet; then
|
|
echo "No demo changes to commit."
|
|
exit 0
|
|
fi
|
|
git commit -m "chore(demo): regenerate gallery"
|
|
git push origin HEAD:${{ github.ref_name }}
|