$ show github-community-projects/stale-repos
This repository provides a GitHub Action (stale-repos) that scans a GitHub organization or user account to identify repositories that have been inactive for a configurable number of days. It is implemented as a Python script packaged in a Docker container, using the PyGithub library to interact with the GitHub API. The action supports authentication via personal access token or GitHub App installation, and can optionally include additional metrics such as days since last release or pull request. Output is generated as both a Markdown report and JSON, and can be automatically added to the GitHub Actions workflow summary. The codebase is well-structured with clear separation of concerns (auth, env, markdown, main logic), comprehensive test coverage, and modern Python tooling (uv, type hints, linting). It is actively maintained with a robust CI/CD pipeline and follows semantic versioning.
The LLM identified 2 files worth highlighting for reuse:
Provides a self-contained function `auth_to_github` that handles authentication to GitHub.com or GitHub Enterprise using either a personal access token or GitHub App installation credentials. It encapsulates the logic for choosing the appropriate authentication method, including handling of GHE base URLs and app-only enterprise mode. This module is cleanly separated from the rest of the codebase, has no internal dependencies beyond the PyGithub library, and could be reused in any Python project that needs to authenticate to the GitHub API.
Defines an `EnvVars` data class and helper functions `get_bool_env_var` and `get_int_env_var` for parsing environment variables with proper type conversion and defaults. The `get_env_vars` function loads a `.env` file (when not in test mode) and returns a validated `EnvVars` instance. This module demonstrates a clean pattern for centralizing environment configuration, with clear error handling for missing or invalid variables. It is fully self-contained and can be extracted into other Python projects that need robust environment variable management.