Skip to main content

📊 GitHub Statistics

Linux Foundation Source Code License OpenSSF Scorecard

Daily, visual activity statistics for a GitHub organisation, a set of its repositories, or a single repository. Pull requests, issues and CI each get a 3D bar chart with one bar per day across a configurable window, with contributor leaderboards beneath. A Python command line tool generates the output as a GitHub Pages site, and a thin composite action wraps it for use in workflows.

🗒️ Published reports

https://lfreleng-actions.github.io/github-statistics-action/

The daily workflow rebuilds the site at 05:00 UTC; see Secrets and variables for its settings.

Usage

permissions:
  actions: read
  checks: read
  contents: read
  issues: read
  pull-requests: read

steps:
  - uses: lfreleng-actions/github-statistics-action@<commit-sha>  # vX.Y.Z
    id: statistics
    with:
      org: lfreleng-actions
      token: ${{ steps.app-token.outputs.token }}
      config: ${{ secrets.GHS_CONFIG || vars.GHS_CONFIG }}
      org_bots: ${{ vars.GHS_ORG_BOTS }}
      output_dir: site

The action runs github-statistics run: for each target it clears the target's img/, data/ and repos/ directories, collects, renders the charts, writes the JSON exports and the target's pages, then writes the landing page. command: scope instead resolves the public repositories in scope and publishes them as outputs.

The action runs its own source: the tree GitHub fetched for the ref you pinned, installed with its dependencies and build backend from uv.lock, so the ref you pin is the code that runs. The action rebuilds its own package on every run, since uv would otherwise reuse a wheel cached from an earlier revision where its cache outlives a job. tool_version runs a published github-statistics release instead.

Inputs

Every input is optional and defaults to the empty string. The action passes a flag to the tool when its input holds a value, so an older release named by tool_version never receives a flag it does not know. List inputs accept commas, spaces or newlines between items.

Input Description
command run (default) or scope
config Configuration as JSON, raw or base64; see Configuration
org Owner to report on: shorthand for a one-target configuration
repositories Repository names or globs to keep
exclude Repository names or globs to drop; refused together with repositories
repo owner/name for repository scope
token Token to read GitHub with (default: the job's github.token)
days Window length in days
until Last day of the window, YYYY-MM-DD (default: yesterday, UTC)
output_dir Site root (default site)
cache_dir Store root (default ~/.cache/github-statistics)
budget REST requests this run may spend
max_minutes Minutes collection may take (default: no limit); the stages after it still run
refresh true to ignore watermarks and re-read the window (run)
strict true to exit 2 when a repository was unreadable (run)
org_bots The organisation's own bots; replaces the configured list
external_bots Bots from outside the organisation; replaces the configured list
members Humans counted as members; replaces the configured list
member_orgs Organisations whose public members count; replaces the configured list
ignore_logins Accounts left out of every output; replaces the configured list
dated_membership true or false: count a public member on the days of its membership alone
repository_pages true or false: add a page per active repository (site.repository_pages)
tool_version github-statistics release to run instead of the action's own source

The action carries the token as GITHUB_TOKEN, so a configuration used with the action leaves token_env at its default. With command: scope, setting refresh or strict to true fails: neither applies to scope.

Outputs

Output Command Description
site_dir run Directory holding the site
requests_used run REST requests the run spent
coverage_complete run true when every day of every metric is complete
gap_days run Days the charts show as gaps, summed over targets
degraded run true when coverage stays degraded over consecutive runs
degraded_reason run One line naming each degradation trigger, at most 500 chars
unclassified_bots run Comma-separated bots that no identity list names
repositories scope Comma-separated public repositories in scope
repository_count scope Number of public repositories in scope

The run also appends its collection and coverage tables and the site location to the job summary, and warns about each unclassified bot with the configuration keys to add it to.

Exit codes

Code Meaning
0 Success; a spent budget still renders and builds the site
1 Invalid configuration, or another failure
2 strict set and a repository was unreadable
3 GitHub rejected the token; the run stops before rendering

Token permissions

The tool reads and never writes. Grant read access alone:

Scope Token Read permissions
Organisation App installation token naming the resolved public repositories, or a fine-grained PAT limited to public repositories metadata, issues, pull requests, actions, checks
Repository list Same, for those repositories same
Single repo The job's GITHUB_TOKEN same, through the job's permissions

Never grant write or organisation permissions. A 401 stops the run with exit code 3; a 403 on one repository marks it unreadable for the run, and the coverage table says so.

Configuration

The config input, or --config-data on the command line, takes the configuration as JSON, raw or base64; --config takes a file. A complete example (design Appendix A):

{
  "version": 1,
  "identities": {
    "org_bots": [
      "lf-releng-issues-triage-bot[bot]",
      "lf-releng-code-monkey-bot[bot]",
      "lf-releng-code-review-bot[bot]"
    ],
    "external_bots": [
      "dependabot[bot]",
      "pre-commit-ci[bot]",
      "copilot-pull-request-reviewer[bot]",
      "Copilot",
      "github-actions[bot]",
      "sonarqubecloud[bot]"
    ],
    "members": [],
    "member_orgs": [],
    "ignore_logins": []
  },
  "targets": [
    {
      "owner": "lfreleng-actions",
      "token_env": "GITHUB_TOKEN",
      "exclude": ["test-tags-*"],
      "scan_archived": false,
      "scan_forks": false,
      "scan_templates": true,
      "identities": {}
    }
  ],
  "window": { "days": 365 },
  "metrics": {
    "pull_requests": true,
    "issues": true,
    "workflows": true,
    "workflow_outcomes": false
  },
  "classes": ["all", "member", "external", "org_bot", "external_bot"],
  "render": {
    "width": 3840,
    "height": 2160,
    "derivatives": [1920],
    "svg": false,
    "palette": {},
    "back_on_tie": {
      "pull_requests": "closed",
      "issues": "closed",
      "workflows": "jobs"
    }
  },
  "contributors": { "top_n": 100, "columns": [] },
  "budget": { "rest": 3000, "graphql_points": 1500, "reserve": 500 },
  "output": { "directory": "site" },
  "site": { "repository_pages": false },
  "cache": { "directory": null },
  "notify": {
    "degraded": {
      "unreadable_runs": 2,
      "unfinished_runs": 3,
      "partial_runs": 3,
      "recent_days": 7
    }
  }
}

Identities

Each identity list is available at every level:

Key Config JSON (identities.*) CLI Action input Variable for the action input
Our bots org_bots --org-bots org_bots vars.GHS_ORG_BOTS
External bots external_bots --external-bots external_bots vars.GHS_EXTERNAL_BOTS
Extra members members --members members vars.GHS_MEMBERS
Member orgs member_orgs --member-orgs member_orgs vars.GHS_MEMBER_ORGS
Ignored logins ignore_logins --ignore-logins ignore_logins vars.GHS_IGNORE_LOGINS
Dated members dated_membership --dated-membership dated_membership vars.GHS_DATED_MEMBERSHIP

A level that sets a key replaces that key's list from the levels below it. Precedence, highest first: command line flags and the action inputs that become them; targets[].identities for that target; top-level identities; the built-in defaults, which are empty lists, member_orgs equal to the target owner and dated_membership off.

By default the members listed today count as members for the whole window. dated_membership counts a public member on the days the organisation's public list held it and on no others, with one exception: a login listed on the organisation's first read counts from the start of the window, not from that read's day, since the store knows nothing earlier. A first read on 3 March still counts that login's activity on 1 March as a member's. A login that first appears on a later read counts from that day, and every login stops counting the day after its last appearance on the list. A login listed on 5 March and missing from the next read on 7 March counts as external on 6 March: membership does not extend through the gap between reads.

Secrets and variables

.github/workflows/statistics.yaml collects, renders and deploys the published site every day, and on workflow_dispatch with optional repositories and refresh inputs. It reads these from the production environment, the repository or the organisation, and the nearest one of a name wins:

Name Kind Purpose
LF_RELENG_BOT_CLIENT_ID Variable Client ID of the organisation App that mints the read token
LF_RELENG_BOT_PRIVATE_KEY Secret Private key of that App
GHS_CONFIG Secret or variable Configuration JSON, raw or base64; the secret wins when both exist
GHS_STORE_KEY Secret Passphrase that encrypts the store in the cache and the artifact
GHS_ORG_BOTS Variable Feeds the org_bots input
GHS_EXTERNAL_BOTS Variable Feeds the external_bots input
GHS_MEMBERS Variable Feeds the members input
GHS_MEMBER_ORGS Variable Feeds the member_orgs input
GHS_IGNORE_LOGINS Variable Feeds the ignore_logins input
GHS_DATED_MEMBERSHIP Variable Not passed yet: set identities.dated_membership in GHS_CONFIG
GHS_REPOSITORY_PAGES Variable Feeds the repository_pages input
SLACK_BOT_TOKEN Secret Bot token that posts the failure and degraded-coverage notices
SLACK_CHANNEL_ID Variable Channel for the failure and degraded-coverage notices

Every one is optional except the App pair, which the workflow needs whenever the scope holds a repository. The action passes its token to the tool as GITHUB_TOKEN, so a GHS_CONFIG must leave each target's token_env at its default. The workflow sets the store root itself: a cache.directory in GHS_CONFIG has no effect there. Without GHS_STORE_KEY the workflow neither restores nor saves the store and says so in a notice; each run then backfills from empty. Without both Slack settings the workflow sends no Slack notice and warns instead. When the run's degraded output is true, the notify-degraded job posts its degraded_reason to the same channel; that job never fails the workflow.

The App token names the public repositories the scope resolves to, with read access alone and no organisation permission, so it cannot read a private repository. An App token names at most 500 repositories: an organisation with more fails the run, and needs a fine-grained personal access token limited to public repositories instead. The workflow restores the store from the Actions cache, or on a miss from the newest github-statistics-store artifact uploaded by its own scheduled or dispatched runs on the default branch.

Before the first run, set the repository's Pages source to GitHub Actions.

Running locally

uv runs a published release without installing it:

export GITHUB_TOKEN="$(gh auth token)"
uvx github-statistics run --repo lfreleng-actions/github-statistics-action \
  --budget 200 --output-dir site
uvx github-statistics scope --org lfreleng-actions --format csv

Open site/index.html in a browser to view the result.

--max-minutes N stops collection N minutes after the command starts, as a spent budget does: the run exits 0 and still renders, exports and builds the site, and the next run resumes. It overrides budget.minutes, which sets no time limit by default.

Logging

Every command logs its progress to stderr at INFO: each collect step as it starts and ends, with the REST requests and GraphQL points spent and left, and a line per repository per step with what it read and stored. Timestamps are in UTC. Set --log-level (debug, info, warning or error) before the command, or GHS_LOG_LEVEL; the option wins. Log lines never carry a token. The summary tables stay on stdout.

Development

The project uses uv and needs Python 3.11 or later. Install the locked dependencies and run the tests:

uv sync
uv run pytest
uv run github-statistics --version

Install the commit hooks with prek, then run them against the files a change touches:

prek install -t pre-commit -t commit-msg
prek run --files <files>

CI runs build-test.yaml on pull requests, and build-test-release.yaml builds, tests and publishes to TestPyPI then PyPI on a tag push.

Metadata

Release files for github-statistics 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for github-statistics 0.4.0
File Size Uploaded Provenance Actions
github_statistics-0.4.0.tar.gz 159.8 kB With provenance Details for github_statistics-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for github-statistics 0.4.0
File Interpreter ABI Platform Actions
github_statistics-0.4.0-py3-none-any.whl Python 3 none any Details for github_statistics-0.4.0-py3-none-any.whl

Total release size: 370.0 kB

Release files / github_statistics-0.4.0.tar.gz

Download URL github_statistics-0.4.0.tar.gz
Size 159.8 kB
Tags Source
SHA-256 checksum
How to use checksums
25a2b73cc5a5b88a84def2c3d9e900fbe3f9f851ec746636c01a6e2f979dffad
BLAKE2b-256 checksum
How to use checksums
c846c1d698034d7d01f940e6eb963634f855939307fb5e971ad1ee67af93236f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / github_statistics-0.4.0-py3-none-any.whl

Download URL github_statistics-0.4.0-py3-none-any.whl
Size 210.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e330fad16720c81ccea580ebf9e6902f0aa38d459f3bcf133b7dd4fb64b7b747
BLAKE2b-256 checksum
How to use checksums
56bd5ab6be19700d9786ac3788197f4c729eccd04b3a0ee68bfc207d48408282
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for github-statistics 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for github_statistics-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page