mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-05-14 14:58:27 +00:00
643a15862b
- Add GraphQL client fetching profile, stats, language aggregation, and per-repo commit histograms for the productive-time heatmap. - Render real SVG cards (profile details, top languages, stats grid, weekday×hour heatmap) with XML escaping and thousands-formatted numbers. - Expand theme palette to 30 built-ins ported from github-readme-stats; add -list-themes, multi-theme rendering, and 'all' shortcut. - Package as Docker-based GitHub Action (action.yml, Dockerfile, entrypoint.sh) with optional auto-commit of generated cards. - Release workflow publishes GHCR image and cross-platform binaries on v* tags. - Unit tests cover rendering, XML escape, number formatting, language sort.
59 lines
1.6 KiB
Bash
59 lines
1.6 KiB
Bash
#!/bin/sh
|
|
# Entrypoint for the ghstats GitHub Action.
|
|
# Inputs are passed via INPUT_* environment variables (set by the Action runtime).
|
|
# This script translates them into ghstats CLI flags and optionally commits the
|
|
# generated SVGs back to the repository.
|
|
|
|
set -eu
|
|
|
|
user="${INPUT_USER:-}"
|
|
token="${INPUT_TOKEN:-${GITHUB_TOKEN:-}}"
|
|
out="${INPUT_OUT:-output}"
|
|
themes="${INPUT_THEMES:-dracula}"
|
|
tz="${INPUT_TZ:-UTC}"
|
|
top_repos="${INPUT_TOP_REPOS:-10}"
|
|
commits_per_repo="${INPUT_COMMITS_PER_REPO:-100}"
|
|
commit_changes="${INPUT_COMMIT_CHANGES:-false}"
|
|
commit_message="${INPUT_COMMIT_MESSAGE:-chore: update ghstats cards}"
|
|
commit_branch="${INPUT_COMMIT_BRANCH:-}"
|
|
author_name="${INPUT_AUTHOR_NAME:-github-actions[bot]}"
|
|
author_email="${INPUT_AUTHOR_EMAIL:-41898282+github-actions[bot]@users.noreply.github.com}"
|
|
|
|
if [ -z "$user" ]; then
|
|
echo "::error::input 'user' is required" >&2
|
|
exit 2
|
|
fi
|
|
|
|
mkdir -p "$out"
|
|
|
|
echo "Running ghstats for user=$user themes=$themes out=$out"
|
|
ghstats \
|
|
-user "$user" \
|
|
-token "$token" \
|
|
-out "$out" \
|
|
-themes "$themes" \
|
|
-tz "$tz" \
|
|
-top-repos "$top_repos" \
|
|
-commits-per-repo "$commits_per_repo"
|
|
|
|
if [ "$commit_changes" = "true" ]; then
|
|
workspace="${GITHUB_WORKSPACE:-/github/workspace}"
|
|
cd "$workspace"
|
|
git config --global --add safe.directory "$workspace"
|
|
git config user.name "$author_name"
|
|
git config user.email "$author_email"
|
|
|
|
if [ -n "$commit_branch" ]; then
|
|
git fetch origin "$commit_branch" || true
|
|
git checkout -B "$commit_branch"
|
|
fi
|
|
|
|
git add "$out"
|
|
if git diff --cached --quiet; then
|
|
echo "No card changes to commit."
|
|
else
|
|
git commit -m "$commit_message"
|
|
git push origin HEAD
|
|
fi
|
|
fi
|