Skip to content

nitzcard/rerun_pls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GitHub PR Workflow Rerun Tools ๐Ÿš€

A comprehensive toolkit for rerunning failed GitHub Actions workflows on Pull Requests. Available in multiple implementations: Web App, TypeScript, Bash Script, and Interactive CLI.

๐ŸŽฏ Quick Start

# Web App (Best UX) ๐ŸŒŸ
npm run start:web

# Interactive CLI
npm run start:interactive

# Bash Script (Fast & Simple)
npm run start:gh

# TypeScript (Full-featured)
npm start:js

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ web/                       # Modern Web Application
โ”‚   โ”œโ”€โ”€ index.html            # Web UI
โ”‚   โ”œโ”€โ”€ app.ts                # Frontend TypeScript
โ”‚   โ”œโ”€โ”€ app.js                # Compiled JavaScript
โ”‚   โ””โ”€โ”€ styles.css            # Modern CSS with dark/light themes
โ”œโ”€โ”€ index.ts                   # Original TypeScript implementation
โ”œโ”€โ”€ index.test.ts             # TypeScript tests
โ”œโ”€โ”€ rerun-with-gh.sh          # Bash script (GitHub CLI)
โ”œโ”€โ”€ rerun-with-gh.test.sh     # Bash script tests
โ”œโ”€โ”€ interactive-cli.ts        # Interactive CLI wrapper
โ””โ”€โ”€ interactive-cli.test.ts   # Interactive CLI tests

๐Ÿ”ง Installation

npm install

Prerequisites:

  • Node.js 18+
  • GitHub CLI (gh) installed and authenticated: gh auth login (for CLI/Bash versions)

๐ŸŽฎ Usage Options

1. Web Application (Best UX) ๐ŸŒŸ

npm run start:web

Features:

  • โœจ Modern responsive web interface
  • ๐ŸŒ™ Dark/Light theme support
  • ๐Ÿ” Searchable author selection with auto-complete
  • ๐Ÿ“‹ Visual PR selection with approval status
  • โšก Real-time form validation
  • ๐Ÿ’พ Configuration save/load from JSON files
  • ๐ŸŽฏ Auto-loading of authors and PRs
  • ๐Ÿ“Š Detailed results display with proper contrast

Web Interface:

  • Smart form validation with auto-focus on errors
  • Searchable dropdown for active contributors (last 6 months)
  • PR status display with emojis (โœ… approved, โณ pending)
  • Auto-loading PRs when author is selected
  • Configuration tips and file management

2. Interactive CLI ๐Ÿ’ป

npm run rerun

Features:

  • โœจ Beautiful interactive menus
  • ๐Ÿ”ง Configuration wizard
  • Automatic config saving
  • ๐ŸŽจ Colorized output

Interactive Menu:

๐Ÿš€ GitHub PR Workflow Rerun - Interactive CLI
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

? What would you like to do?
โฏ ๐Ÿ”„ Rerun failed workflows for PR author
  ๐ŸŽฏ Rerun specific PR numbers  
  ๐Ÿ“‹ List failed runs (no rerun)
  โš™๏ธ  Configure settings
  ๐Ÿ’พ Save current configuration
  โŒ Exit

3. Bash Script (Fastest) โšก

# Use .env.gh configuration
npm run start:gh

# Or direct environment variables
AUTHOR=username DRY_RUN=false src/rerun-with-gh.sh

Features:

  • ๐Ÿš€ Super fast execution
  • ๐Ÿ“ฆ No dependencies (just gh CLI)
  • ๐Ÿ”ง Environment file support
  • ๐ŸŽจ Colorized logging

4. TypeScript Implementation (Original) ๐Ÿ“

npm start

Features:

  • ๐Ÿ” Full GitHub API integration
  • ๐Ÿ“Š Detailed logging with Winston
  • ๐Ÿงช Comprehensive test suite
  • ๐Ÿ“‹ Table formatting

๐Ÿ”„ Method Comparison

Feature Web App Interactive CLI Bash Script TypeScript
User Experience โญโญโญโญโญ โญโญโญโญ โญโญโญ โญโญ
Visual Interface โœ… Modern UI โœ… Menus โŒ Terminal โŒ Terminal
Speed โญโญโญโญ โญโญโญ โญโญโญโญโญ โญโญโญ
Author Selection โœ… Searchable โœ… Interactive โŒ Manual โŒ Manual
PR Selection โœ… Visual + Status โœ… List โŒ All/Manual โŒ All/Manual
Configuration โœ… Save/Load Files โœ… Auto-save โœ… .env files โŒ Env vars only
Theme Support โœ… Dark/Light โŒ Terminal โŒ Terminal โŒ Terminal
Dependencies Node.js + Browser Node.js gh CLI only Node.js
Best For Daily use Setup/Config Quick scripts Development

Recommendation: Use the Web App for the best experience, Bash Script for automation/scripts.

โš™๏ธ Configuration

Option A: Environment File (.env.gh)

REPO_URL=https://github.com/owner/repo
AUTHOR=username
MODE=workflows
DRY_RUN=true
PR_NUMBERS=123,456

Option B: Environment Variables

AUTHOR=username MODE=jobs DRY_RUN=false npm run start:gh

Option C: Interactive Configuration

npm run rerun
# Select "โš™๏ธ Configure settings"

๐Ÿ“ Configuration Options

Variable Description Values Default
AUTHOR Filter PRs by author GitHub username -
MODE Rerun mode workflows, jobs workflows
DRY_RUN Preview mode true, false true
REPO_URL Target repository GitHub URL or owner/repo Current repo
PR_NUMBERS Specific PRs Comma-separated All PRs

Mode Differences:

  • workflows: Rerun entire workflow (all jobs)
  • jobs: Rerun only failed jobs (faster)

๐Ÿงช Testing

# Run all tests
npm run test:all

# Individual test suites
npm run test              # TypeScript tests
npm run test:gh           # Bash script tests  
npm run test:interactive  # Interactive CLI tests

Test Coverage:

  • โœ… TypeScript: 9 tests (API integration, workflow logic)
  • โœ… Bash Script: 10 tests (CLI functionality, config loading)
  • โœ… Interactive CLI: 3 tests (module structure)

๐Ÿ“– Examples

Rerun Failed Workflows for Specific Author

# Interactive
npm run rerun
# Select "๐Ÿ”„ Rerun failed workflows for PR author"

# Bash
AUTHOR=myusername DRY_RUN=false npm run start:gh

# TypeScript
AUTHOR=myusername DRY_RUN=false npm start

Rerun Specific PR Numbers

# Interactive
npm run rerun
# Select "๐ŸŽฏ Rerun specific PR numbers"

# Bash
PR_NUMBERS=123,456 DRY_RUN=false npm run start:gh

# Direct
npm run interactive -- --pr-numbers "123,456" --no-interactive

List Failed Runs (No Rerun)

# Interactive
npm run rerun
# Select "๐Ÿ“‹ List failed runs (no rerun)"

# Bash (dry run)
AUTHOR=username DRY_RUN=true npm run start:gh

๐Ÿ”„ Workflow Comparison

Feature Interactive CLI Bash Script TypeScript
UX โญโญโญโญโญ โญโญโญ โญโญ
Speed โญโญโญ โญโญโญโญโญ โญโญ
Features โญโญโญโญโญ โญโญโญโญ โญโญโญโญโญ
Setup โญโญโญ โญโญโญโญโญ โญโญ
Dependencies โญโญโญ โญโญโญโญโญ โญโญ

Recommendation:

  • ๐ŸŽฏ New users: Interactive CLI
  • โšก Power users: Bash Script
  • ๐Ÿ”ฌ Developers: TypeScript (for learning GitHub API)

๐Ÿ› Troubleshooting

GitHub CLI Not Found

# Install GitHub CLI
brew install gh
# Or visit: https://cli.github.com/

# Authenticate
gh auth login

Permission Denied

chmod +x src/rerun-with-gh.sh
chmod +x src/rerun-with-gh.test.sh

Repository Not Found

# Make sure you have access to the repository
gh repo view owner/repo

# Or specify explicitly
REPO_URL=https://github.com/owner/repo npm run start:gh

๐ŸŽ‰ Contributing

  1. Run tests: npm run test:all
  2. Test all implementations:
    • Interactive: npm run rerun
    • Bash: npm run start:gh
    • TypeScript: npm start

๐Ÿ“Š Performance

Implementation Startup Time Memory Dependencies
Bash Script ~0.1s ~5MB gh only
Interactive CLI ~1.5s ~25MB Node.js + packages
TypeScript ~2s ~30MB Node.js + packages

๐Ÿ Summary

Three ways to rerun failed GitHub workflows:

  1. ๐ŸŽฎ Interactive CLI: Best user experience with guided menus
  2. โšก Bash Script: Fastest execution with GitHub CLI
  3. ๐Ÿ“ TypeScript: Full-featured with comprehensive API integration

Choose based on your needs:

  • Learning: TypeScript implementation
  • Daily use: Interactive CLI
  • Automation: Bash script

Happy workflow rerunning! ๐Ÿš€

  • processPR(): Main processing logic for individual PRs

Testing

The project uses Node.js built-in testing with ts-node for TypeScript support. Tests cover:

  • URL parsing for different GitHub formats
  • Configuration validation
  • Status and conclusion filtering logic
  • PR number parsing
  • Mode enum validation

All functions are exported for testing while maintaining clean module execution.

Operation Modes

Workflows Mode (MODE=workflows)

  • Reruns entire workflow runs that have failed
  • Good for cases where the entire workflow needs to be restarted
  • More comprehensive but uses more CI resources

Jobs Mode (MODE=jobs)

  • Reruns only the specific jobs that failed within workflows
  • More targeted and efficient
  • Preserves successful job results within the same workflow run

Example Output

[21:21:59] info: Limiting to PR(s): 8212
[21:21:59] info: Working on repo: cardinalops/cardinalops
[21:21:59] info: Mode: RERUN FAILED JOBS
[21:21:59] info: Found 1 open PR(s) to process.
[21:21:59] info: PR #8212: fix: COPS-10604 - MITRE - Exposures - user should not be able to remove prevention products.. (author: nitzcard)

Contributing

The codebase follows TypeScript best practices with:

  • Enum-based configuration
  • Proper error handling
  • Comprehensive logging
  • Modular function design
  • Full test coverage

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors