A command-line tool to analyze GitHub repository artifacts and identify what's consuming your GitHub Actions storage quota.
- Complete Repository Analysis: Scans ALL your repositories (public AND private) for GitHub Actions workflows and artifacts
- Storage Usage Breakdown: Shows exactly how much storage each repository is using
- Artifact Details: Lists individual artifacts with sizes, creation dates, and expiration status
- Smart Recommendations: Provides actionable advice for optimizing storage usage
- Multiple Output Formats: Supports table, JSON, and CSV output formats
- Expired Artifact Detection: Identifies artifacts that can be safely removed
- Interactive Cleanup Mode: Built-in artifact deletion with safety prompts
- Rate Limit Friendly: Respects GitHub API rate limits with intelligent throttling
npm install -g github-artifacts-analyzergit clone https://github.com/shanselman/github-artifacts-analyzer.git
cd github-artifacts-analyzer
npm install
npm run build📝 TypeScript Project: Source files are in
src/(TypeScript), compiled output indist/(JavaScript). Always runnpm run buildafter changes.
- Go to GitHub Settings > Developer settings > Personal access tokens
- Click "Generate new token (classic)"
- Select these scopes:
repo(Full control of private repositories)read:user(Read access to user profile data)actions:read(Read access to actions and workflows)
export GITHUB_TOKEN=$(gh auth token)export GITHUB_TOKEN="your_token_here"Or create a .env file:
GITHUB_TOKEN=your_token_here
# Build first (required for TypeScript)
npm run build
# Basic analysis (includes both public and private repos)
github-artifacts analyze
# Or use npm scripts (includes build step)
npm run analyze
# Analyze specific user
npm run analyze -- --username shanselman
# Include expired artifacts
github-artifacts analyze --include-expired
# Show top 20 repositories
github-artifacts analyze --top 20
# Export to JSON
github-artifacts analyze --format json --output results.json
# Export to CSV
github-artifacts analyze --format csv --output results.csv
# Interactive cleanup mode - DELETE artifacts to save space
github-artifacts analyze --cleanup# Analyze a single repository
github-artifacts repo shanselman hanselminutes-core
# Include expired artifacts
github-artifacts repo shanselman hanselminutes-core --include-expired
# JSON output
github-artifacts repo shanselman hanselminutes-core --format json
# Interactive cleanup mode for this repository
github-artifacts repo shanselman hanselminutes-core --cleanup-t, --token <token>: GitHub Personal Access Token (or set GITHUB_TOKEN env var)
-u, --username <username>: GitHub username (defaults to authenticated user)-f, --format <format>: Output format (table|json|csv) [default: table]-o, --output <file>: Output file path--include-expired: Include expired artifacts in analysis [default: false]--min-size <bytes>: Minimum artifact size to include in bytes [default: 0]--top <count>: Show top N repositories by storage usage [default: 10]--cleanup: Interactive cleanup mode - delete artifacts to save space [default: false]
-f, --format <format>: Output format (table|json|csv) [default: table]--include-expired: Include expired artifacts in analysis [default: false]--cleanup: Interactive cleanup mode for this repository [default: false]
🚀 GitHub Artifacts Storage Analysis Summary
============================================================
┌─────────────────────────────┬──────────┐
│ Metric │ Value │
├─────────────────────────────┼──────────┤
│ Total Repositories │ 121 │
│ Repositories with Workflows │ 15 │
│ Repositories with Artifacts │ 8 │
│ Total Artifacts │ 234 │
│ Total Storage Used │ 1.87 GB │
│ Active Artifacts │ 156 (1.2 GB) │
│ Expired Artifacts │ 78 (670 MB) │
└─────────────────────────────┴──────────┘
📊 Top 10 Repositories by Storage Usage
================================================================================
┌────────────────────────────┬──────────┬──────────┬─────────────┬─────────────┬─────────────┐
│ Repository │ Workflows│ Artifacts│ Total Size │ Active Size │ Expired Size│
├────────────────────────────┼──────────┼──────────┼─────────────┼─────────────┼─────────────┤
│ shanselman/hanselminutes-core │ 3 │ 45 │ 678.5 MB │ 456.2 MB │ 222.3 MB │
│ shanselman/TinyOS │ 1 │ 23 │ 234.1 MB │ 156.7 MB │ 77.4 MB │
│ shanselman/babysmash │ 2 │ 12 │ 123.4 MB │ 89.2 MB │ 34.2 MB │
└────────────────────────────┴──────────┴──────────┴─────────────┴─────────────┴─────────────┘
- Workflows: Number of GitHub Actions workflows in the repository
- Artifacts: Total number of artifacts across all workflow runs
- Total Size: Combined size of all artifacts (active + expired)
- Active Size: Size of artifacts that haven't expired yet
- Expired Size: Size of artifacts that have expired and can be deleted
- Name: Artifact name as specified in the workflow
- Size: Storage space consumed by the artifact
- Workflow: Name of the workflow that created the artifact
- Created: When the artifact was created
- Expires: When the artifact will expire
- Status: Whether the artifact is active or expired
The tool includes a powerful interactive cleanup feature that safely deletes artifacts:
# Analyze and cleanup all repositories
github-artifacts analyze --cleanup
# Cleanup specific repository
github-artifacts repo shanselman hanselminutes-core --cleanup- Identifies Safe Deletions: Finds expired artifacts and old active artifacts
- Shows Potential Savings: Calculates how much space you'll free up
- Interactive Prompts: Asks for confirmation before deleting anything
- Rate Limited: Respects GitHub API limits during deletion
- Progress Feedback: Shows real-time deletion progress
- Expired Artifacts: Always safe to delete, frees up space immediately
- Old Active Artifacts: Artifacts older than 30 days that might not be needed
- Large Artifacts: Highlights unusually large artifacts for review
The tool will NEVER delete anything without your explicit confirmation.
- Compress files before uploading as artifacts
- Use selective file inclusion patterns
- Set shorter retention periods for temporary artifacts
- Clean up build artifacts between jobs when possible
The tool highlights artifacts larger than 50MB. Consider:
- Breaking large artifacts into smaller pieces
- Using external storage for large files
- Optimizing build outputs
Create workflows that automatically clean up old artifacts:
name: Cleanup Artifacts
on:
schedule:
- cron: '0 0 * * 0' # Weekly
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Delete old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: '30 days'- Node.js 18+
- TypeScript
- GitHub Personal Access Token
git clone <repository>
cd github-artifacts-analyzer
npm installnpm run dev # Run in development mode
npm run build # Build TypeScript
npm run start # Run built version
npm run clean # Clean build directory# Test with your own repositories
npm run dev -- analyze --username YOUR_USERNAME
# Test single repository
npm run dev -- repo YOUR_USERNAME YOUR_REPO- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
MIT License - see LICENSE file for details.
"API rate limit exceeded"
- The tool includes built-in rate limiting, but with many repositories, you might hit limits
- Wait and try again, or run the analysis in smaller batches
"Repository not found or no access"
- Ensure your token has the correct permissions
- Check that the repository exists and you have access
"Access forbidden - check token permissions"
- Verify your token has
repo,read:user, andactions:readscopes - For organization repositories, you might need additional permissions
"No artifacts found"
- Repository might not have any GitHub Actions workflows
- Workflows might not generate artifacts
- Artifacts might have all expired
- Check the GitHub API status: https://www.githubstatus.com/
- Verify your token permissions
- Try analyzing a single repository first
- Open an issue with detailed error messages
- Bulk artifact deletion functionality
- Integration with GitHub CLI
- Webhook support for real-time monitoring
- Dashboard web interface
- Artifact content analysis
- Cost estimation features
- Organization-wide analysis
Made with ❤️ for the set of all developers who are Scott Hanselman