mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-09-04 00:17:25 +00:00
ci(demo): add workflow rendering every card for every theme (#1)
Runs on push to main (skipping its own demo/output/markdown commits), builds the ghstats binary, renders every theme for the repo owner, and writes a demo/README.md gallery back to main.
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
name: Demo
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- "demo/**"
|
||||
- "output/**"
|
||||
- "**.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 README
|
||||
env:
|
||||
OWNER: ${{ github.repository_owner }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
cards=(
|
||||
profile-details
|
||||
repos-per-language
|
||||
most-commit-language
|
||||
stats
|
||||
productive-time
|
||||
contributions
|
||||
most-commit-language-all-time
|
||||
productive-time-all-time
|
||||
contributions-all-time
|
||||
)
|
||||
themes=$(./ghstats -list-themes)
|
||||
{
|
||||
echo "# ghstats demo gallery"
|
||||
echo
|
||||
echo "Every card in every theme, rendered for [\`$OWNER\`](https://github.com/$OWNER)."
|
||||
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
|
||||
echo "- [\`$theme\`](#$theme)"
|
||||
done
|
||||
echo
|
||||
for theme in $themes; do
|
||||
dir="demo/$theme"
|
||||
[ -d "$dir" ] || continue
|
||||
echo "## $theme"
|
||||
echo
|
||||
for card in "${cards[@]}"; do
|
||||
svg="$dir/$card.svg"
|
||||
[ -f "$svg" ] || continue
|
||||
echo ""
|
||||
done
|
||||
echo
|
||||
echo "[back to top](#themes)"
|
||||
echo
|
||||
done
|
||||
} > demo/README.md
|
||||
|
||||
- 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 }}
|
||||
Reference in New Issue
Block a user