Skip to main content

keep_github_workflows_active

CI CodeQL License: MIT Open in Codespaces PyPI PyPI - Downloads Code Style: Ruff codecov Maintainability security: bandit

CI cadence: The GitHub Actions CI workflow runs automatically every Monday at 07:00 UTC, in addition to push and pull request triggers.

Overview

keep_github_workflows_active is an automation helper that tends to every GitHub Actions workflow in a user's repositories. It exists to remove the routine maintenance burden that accrues when repositories go quiet and Actions start to disable schedules automatically.

The automation focuses on two responsibilities:

  1. Keep all workflows active – iterate every repository owned by the configured user and flip disabled workflows back to the active state so cron-based automation continues to run.
  2. Delete stale workflow runs – retain an operator-defined number of the freshest runs per workflow and delete older artifacts so storage quotas and repository hygiene remain under control.

Both behaviors run as part of repository automation (for example on a nightly schedule) once the required GitHub token is in place.

Prerequisites

Generate an access token

The automation requires a fine-grained personal access token with repository scope. You can create one by visiting the GitHub self-service page:

When configuring the token, grant at least the following permissions:

  • Actions: Read/Write (needed to toggle workflow states and delete runs).
  • Metadata: Read (lets the script discover repositories you own).

Tokens expire automatically. Renew them before the expiry hits to keep the automation alive. The previous test token that powered the repository expired on January 19, 2025, so any current setup must already use a newer credential.

Store the token as a repository secret

Add the token to the repository's secrets so GitHub Actions can inject it at runtime:

Define the following secrets:

  • SECRET_GITHUB_OWNER – GitHub username whose repositories should be scanned.
  • SECRET_GITHUB_TOKEN – the fine-grained personal access token you generated.

Keeping the credentials inside secrets ensures the nightly cleanup workflow can authenticate without hard-coding sensitive values in the repository.

For local development you can place the same keys inside a .env file at the repository root. The automation reads from the environment first and falls back to .env when running outside GitHub Actions.

Note: the included tests and CLI commands exercise the live GitHub API. When SECRET_GITHUB_OWNER and SECRET_GITHUB_TOKEN point at a real account, running make test (or the workflow maintenance commands directly) will re-enable workflows and prune old workflow runs across the configured repositories.

Installation

Install the package locally when you want to run the CLI helpers or contribute changes:

pip install keep_github_workflows_active

Alternative flows (pipx, uv, editable installs, or source builds) are described in INSTALL.md. All supported options expose both the keep_github_workflows_active and keep-github-workflows-active entry points on your PATH.

Python 3.13+ baseline

  • The package targets Python 3.13 and newer. Older interpreters are no longer supported; the codebase relies on modern conveniences such as Path.unlink(missing_ok=True).
  • Runtime modules now use native Python 3.13 type syntax (e.g., list[str], Sequence[str] | None) and drop legacy compatibility helpers.
  • Runtime dependencies include rich-click for the CLI surface and lib_cli_exit_tools for consistent exit handling. Development extras pin the tooling stack (pytest, ruff, pyright, bandit, build, twine, codecov-cli, pip-audit, textual, import-linter) to their latest major releases.
  • Development dependencies were refreshed to the latest stable releases (ruff>=0.14.1, textual>=6.4.0).
  • Continuous integration runs across GitHub's hosted runners (ubuntu-latest, macos-latest, windows-latest) on CPython 3.13 in addition to the most recent 3.x release Actions makes available.

Usage

Once installed and authenticated via repository secrets, schedule the automation from a GitHub Actions workflow (see docs/systemdesign/module_reference.md for the architectural wiring). The CLI remains available for local smoke-tests and packaging checks while the richer workflow management helpers iterate:

keep_github_workflows_active info
keep_github_workflows_active hello
keep_github_workflows_active fail
keep_github_workflows_active --traceback fail
keep_github_workflows_active enable-all-workflows [--owner <user>] [--token <pat>]
keep_github_workflows_active delete-old-workflow-runs [--owner <user>] [--token <pat>] [--keep <n>]
keep-github-workflows-active info
python -m keep_github_workflows_active info

The workflow maintenance commands accept optional flags. When --owner or --token is omitted the CLI falls back to the values discovered via environment variables or the project's .env file. --keep defaults to 50 workflow runs per repository.

Programmatic access is also exposed via the public helpers:

import keep_github_workflows_active as kgwa

kgwa.emit_greeting()
try:
    kgwa.raise_intentional_failure()
except RuntimeError as exc:
    print(f"caught expected failure: {exc}")

kgwa.print_info()

Security

All logging operations sanitize sensitive data before output to prevent credential leakage. The automation redacts:

  • GitHub personal access tokens (ghp_, gho_, etc.)
  • Authorization headers and API keys
  • Token-like patterns in error messages

For complete security documentation including incident response procedures, see SECURITY.md.

Further documentation

Metadata

Release files for keep-github-workflows-active 2.3.4

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

Source distribution (sdist)

Source distribution for keep-github-workflows-active 2.3.4
File Size Uploaded Provenance Actions
keep_github_workflows_active-2.3.4.tar.gz 70.9 kB Without provenance Details for keep_github_workflows_active-2.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for keep-github-workflows-active 2.3.4
File Interpreter ABI Platform Actions
keep_github_workflows_active-2.3.4-py3-none-any.whl Python 3 none any Details for keep_github_workflows_active-2.3.4-py3-none-any.whl

Total release size: 97.2 kB

Release files / keep_github_workflows_active-2.3.4.tar.gz

Download URL keep_github_workflows_active-2.3.4.tar.gz
Size 70.9 kB
Tags Source
SHA-256 checksum
How to use checksums
049321966a29113377b02a4044a49a0552b8e332f191c0bc82825b7f3e486d89
BLAKE2b-256 checksum
How to use checksums
407d9ed1498ebe281f77023b681d5527d51a628d3c94bf36fdbf75fbc6808437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / keep_github_workflows_active-2.3.4-py3-none-any.whl

Download URL keep_github_workflows_active-2.3.4-py3-none-any.whl
Size 26.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7aa97d18bc7236cefb5732768b31519c41dc18162f741202cccfe4f963175e0
BLAKE2b-256 checksum
How to use checksums
b61af33a14fdfb2dcea0d77a9a7890230de04c3b03da13d27cc515157a242330
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for keep-github-workflows-active 2.3.4

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