mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-08-30 18:22:19 +00:00
Split each contribution year into quarterly windows. commitContributionsByRepository caps at 100 repos per query and drops the remainder without signalling it, which a prolific year hits: 2026 returned exactly 100 where the quarterly union returns 108. Warn when a window still comes back at the ceiling instead of reporting a complete list. Add -include-org-repos / include_org_repos so org-owned repos the user administers count toward stars, repo count, repos-per-language and top-starred. Off by default, since enabling it moves those totals for every existing caller. Commit-driven cards already covered org repos through the seed list. Org repos carrying only read or write access are dropped via viewerPermission. Rename Profile.PublicRepos to RepoCount and drop "public" from the card label: the count tracks the fetch filters and includes private repos whenever the token can see them.
67 lines
2.0 KiB
Bash
67 lines
2.0 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}"
|
|
start_of_week="${INPUT_START_OF_WEEK:-sunday}"
|
|
top_repos="${INPUT_TOP_REPOS:-0}"
|
|
commits_per_repo="${INPUT_COMMITS_PER_REPO:-500}"
|
|
include_forks="${INPUT_INCLUDE_FORKS:-true}"
|
|
include_private="${INPUT_INCLUDE_PRIVATE:-true}"
|
|
include_org_repos="${INPUT_INCLUDE_ORG_REPOS:-false}"
|
|
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" \
|
|
-start-of-week "$start_of_week" \
|
|
-top-repos "$top_repos" \
|
|
-commits-per-repo "$commits_per_repo" \
|
|
-include-forks="$include_forks" \
|
|
-include-private="$include_private" \
|
|
-include-org-repos="$include_org_repos"
|
|
|
|
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
|