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

The link to the published site will appear here once the site goes live.

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/ and data/ 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 installs the release named in .github/runtime-pin/requirements.txt, which Dependabot keeps current. tool_version overrides the pin; pull requests and use_local_source: "true" run the action's own source 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 pinned release 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
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
tool_version github-statistics release to run instead of the runtime pin
use_local_source true to run the action's own source (pull requests always do)

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
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" },
  "cache": { "directory": null }
}

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

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 and member_orgs equal to the target owner.

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.

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.1.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.1.0
File Size Uploaded Provenance Actions
github_statistics-0.1.0.tar.gz 129.2 kB Without provenance Details for github_statistics-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 303.7 kB

Release files / github_statistics-0.1.0.tar.gz

Download URL github_statistics-0.1.0.tar.gz
Size 129.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a7d3aa03ddec538383a8e188282345d6f6450c85de6aebf25efc6882d879d149
BLAKE2b-256 checksum
How to use checksums
9ee8a1201dfcc958276201c9f7feeb2cd5bbbab484f47b01220208601828c1f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

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

Download URL github_statistics-0.1.0-py3-none-any.whl
Size 174.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b65e9f67d76825880fd35b9d33fb8489a4bc8583d7ce2fdeb163d2445db3f7aa
BLAKE2b-256 checksum
How to use checksums
8b690c0a4dfd039248b77d038860414ff5242506dcefc79d153f10c0e9ed06fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for github-statistics 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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