CLI to prune GitHub workflow runs
Project description
gh-prune
gh-prune is a command-line utility designed to help you manage and prune GitHub Actions workflow runs efficiently. It interacts with the GitHub CLI (gh) to list, inspect, and delete workflow runs, helping you maintain a clean repository and manage usage limits.
Prerequisites
Before using gh-prune, ensure you have the following installed:
- Python 3.x
- GitHub CLI (
gh):- macOS:
brew install gh - Windows/Linux: See GitHub CLI Installation
- macOS:
- Python Dependencies:
typerrich
Installation
-
Clone the repository:
git clone https://github.com/ifaakash/gh-prune.git cd gh-prune
-
Install dependencies:
pip install typer rich
-
Authenticate with GitHub:
gh auth login --hostname github.com
Build and Run Locally
To build and run the project locally, it is highly recommended to use a separate virtual environment (venv).
-
Create and Activate Virtual Environment:
python3 -m venv venv source venv/bin/activate
-
Build and Install:
rm -rf dist/ python3 -m build pip3 install dist/gh_prune-*.whl --force-reinstall
Usage
The tool is executed via doctor.py. Below are the available commands.
1. Health Check (doctor)
Verifies that the GitHub CLI is installed and correctly authenticated.
python3 doctor.py doctor
2. List Workflows (workflow-list)
Lists all workflows in a specified repository, showing their names, IDs, and states.
Syntax:
python3 doctor.py workflow-list [OWNER/REPO]
Example:
python3 doctor.py workflow-list ifaakash/gh-prune
3. List Workflow Runs (workflow-run-list)
Lists the recent runs of a specific workflow file.
Syntax:
python3 doctor.py workflow-run-list [OWNER/REPO] [WORKFLOW_FILENAME]
Example:
python3 doctor.py workflow-run-list ifaakash/gh-prune pylint.yml
4. Delete Old Runs (workflow-run-delete)
Deletes old workflow runs but keeps a specified number of the most recent ones. Useful for cleaning up history while retaining the latest status.
Syntax:
python3 doctor.py workflow-run-delete [OWNER/REPO] [WORKFLOW_FILENAME] --keep [N] --limit [M]
Options:
--keep: Number of recent runs to keep (default: 5).--limit: Number of runs to fetch for processing (default: 30).--yes/-y: Skip confirmation prompt.
Example:
python3 doctor.py workflow-run-delete ifaakash/news-agent cron-workflow.yml --keep 180 --limit 200
5. Prune All Runs (workflow-run-prune)
Deleting ALL runs for a specific workflow up to a specified limit. Use with caution.
Syntax:
python3 doctor.py workflow-run-prune [OWNER/REPO] [WORKFLOW_FILENAME] --limit [M]
Options:
--limit: Number of runs to fetch and delete (default: 30).--yes/-y: Skip confirmation prompt.
Example:
python3 doctor.py workflow-run-prune ifaakash/news-agent cron-workflow.yml --limit 200
Help
To see a tabular summary of commands and examples directly in the terminal, run:
python3 doctor.py docs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gh_prune-0.1.1.tar.gz.
File metadata
- Download URL: gh_prune-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb2833b36ffc5b82ed32de83d1bad7c6d6e8993574301a43c1a2756e1f171de0
|
|
| MD5 |
140e91b64a12b8f06b4d894bc6484488
|
|
| BLAKE2b-256 |
845d71b62b523661b4c56e66cbef03a301ad119971372079a246ee9578281c73
|
File details
Details for the file gh_prune-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gh_prune-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
023dcceb6b56a5b48c50d6f718a1a3164df0c1dac1d0b86c86e58a596f9b4da2
|
|
| MD5 |
77758878eae542a97f69d4ab266ef35b
|
|
| BLAKE2b-256 |
7b1facdfdc1df355755f20e50a9085627d7b75578a1e8d7adb1566a24c58c7af
|