Skip to content

neiam/ghr-destroy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GitHub Runner Destroyer (ghr-destroy)

Because I learned that 10000 offline ephemeral self hosted runners is a funny thing

A command-line tool to delete GitHub self-hosted runners from a repository using the GitHub API.

Features

  • πŸ—‘οΈ Batch deletion of all self-hosted runners in a repository or organization
  • 🏒 Organization-level support - Delete all runners across an entire organization
  • πŸ” Dry run mode to preview what would be deleted
  • πŸ“΄ Offline-only mode - Filter to delete only offline runners
  • πŸ“„ Pagination support to handle repositories with many runners
  • 🎨 Colorful output with clear status indicators
  • βœ… Safety prompts to prevent accidental deletions
  • πŸ” Token-based authentication with environment variable support

Installation

From Source

git clone <repository-url>
cd ghr-destroy
cargo build --release

The binary will be available at target/release/ghr-destroy.

Usage

Organization-Level Usage (Delete ALL runners in organization)

ghr-destroy --owner myorg --token ghp_your_token_here

Repository-Level Usage (Delete runners from specific repo)

ghr-destroy --owner myorg --repo myrepo --token ghp_your_token_here

Using Environment Variable for Token

export GITHUB_TOKEN=ghp_your_token_here
ghr-destroy --owner myorg --repo myrepo

Dry Run Mode

Preview what would be deleted without actually deleting:

ghr-destroy --owner myorg --repo myrepo --dry-run

Skip Confirmation

Delete all runners without confirmation prompts:

### Delete Only Offline Runners

Target only offline runners for deletion:

```bash
# Organization level - offline runners only
ghr-destroy --owner myorg --offline-only
# Organization level
ghr-destroy --owner myorg --yes
# Repository level
ghr-destroy --owner myorg --repo myrepo --yes
### Custom Pagination

Fetch more runners per page (default is 100):

```bash
ghr-destroy --owner myorg --repo myrepo --per-page 50

Command Line Arguments

Argument Short Description Required Default
--owner -o GitHub organization or username Yes -
--repo -r Repository name (optional - omit for org-level) No -
--token -t GitHub personal access token Yes* -
--dry-run - Preview mode, don't delete No false
--offline-only - Only delete offline runners No false
--yes -y Skip confirmation prompts No false
--per-page - Runners per page for API calls No 100

*Required unless set via GITHUB_TOKEN environment variable

GitHub Token Requirements

Your GitHub personal access token needs the following permissions:

For Organization Repositories:

  • admin:org - To manage organization runners
  • repo - To access repository information

For Personal Repositories:

  • repo - Full repository access

Creating a Token:

  1. Go to GitHub Settings β†’ Developer settings β†’ Personal access tokens
  2. Click "Generate new token (classic)"
  3. Select the required scopes listed above
  4. Copy the generated token

API Endpoints Used

This tool uses the following GitHub REST API endpoints:

  • List runners: GET /repos/{owner}/{repo}/actions/runners
  • Delete runner: DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}

Examples

List and delete all runners (with confirmation):

ghr-destroy -o myorg -r myrepo -t ghp_token123

Dry run to see what would be deleted:

ghr-destroy -o myorg -r myrepo -t ghp_token123 --dry-run

Delete all runners without confirmation:

ghr-destroy -o myorg -r myrepo -t ghp_token123 -y

Delete only offline runners:

# Organization level - offline runners only (with confirmation)
ghr-destroy -o myorg -t ghp_token123 --offline-only

# Repository level - offline runners only (dry run)
ghr-destroy -o myorg -r myrepo -t ghp_token123 --offline-only --dry-run

# Organization level - offline runners only (skip confirmation)
ghr-destroy -o myorg -t ghp_token123 --offline-only --yes

Error Handling

The tool handles various error scenarios:

  • Invalid token: Clear error message about authentication
  • Repository not found: 404 errors are reported clearly
  • Insufficient permissions: Permission errors are explained
  • Network issues: Connection and timeout errors are handled
  • Rate limiting: API rate limit errors are reported

Output Format

The tool provides colorful, informative output:

  • πŸ”„ Busy runners are indicated with a spinning icon
  • πŸ’€ Idle runners are shown with a sleep icon
  • 🟒 Online status in green
  • πŸ”΄ Offline status in red
  • 🟑 Unknown status in yellow

Safety Features

  • Confirmation prompt before deletion (unless --yes is used)
  • Dry run mode to preview operations
  • Clear output showing exactly what will be deleted
  • Error reporting for failed deletions

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

[Add your license information here]

Disclaimer

⚠️ Warning: This tool will permanently delete GitHub self-hosted runners. Use with caution and always test with --dry-run first!

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages