A GitHub Action that automatically comments on PRs with large diffs (1000+ additions by default), showing the change statistics with a humorous touch.
Large PRs are harder to review and more prone to issues slipping through. This action gently reminds contributors to consider breaking up massive changes into smaller, more reviewable chunks.
- 🔍 Automatically detects PRs with large diffs
- 📊 Shows addition and deletion statistics in a clean two-column layout with color indicators
- 🔄 Dynamically updates comment numbers as PR changes
- 🧹 Auto-deletes comment when PR is cleaned up below threshold (rewards good behavior!)
- ⚙️ Configurable threshold for what counts as "large" (default: 1000 additions)
- 🎨 Includes a fun image to keep things light-hearted
Add this action to your repository's workflow:
name: Big Diff Check
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
contents: read
jobs:
check-pr-size:
runs-on: ubuntu-latest
steps:
- name: Check for big diffs
uses: lukasjuhas/big-diff-energy-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
threshold: 1000 # Optional: defaults to 1000| Input | Description | Required | Default |
|---|---|---|---|
github-token |
GitHub token for posting comments | Yes | N/A |
threshold |
Minimum number of additions to trigger the comment | No | 1000 |
title |
Custom title for the comment | No | This PR has some **big diff energy**: |
message |
Custom message to display below the stats | No | That's a lot of changes! Consider breaking this into smaller PRs for easier review. |
image-url |
Custom image URL for the comment | No | https://raw.githubusercontent.com/lukasjuhas/big-diff-energy-action/main/assets/matthew-smoking.jpeg |
This action requires the following permissions:
permissions:
pull-requests: write # To post comments
contents: read # To read PR filesWhen triggered, the action posts a comment like this:
The comment uses a two-column layout with Matthew smoking on the left and stats on the right, with color indicators (🟢 for additions, 🔴 for deletions).
- Triggered on PR open, synchronize, or reopen events
- Fetches all files changed in the PR
- Calculates total additions and deletions
- Smart comment management:
- If above threshold and no comment exists: Posts new comment
- If above threshold and comment exists: Updates comment with new numbers
- If below threshold and comment exists: Deletes comment (rewards cleanup!)
Want to be stricter or more lenient? Adjust the threshold:
- uses: lukasjuhas/big-diff-energy-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
threshold: 500 # Trigger on 500+ additionsPersonalize the comment to match your team's style:
- uses: lukasjuhas/big-diff-energy-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
title: "🐘 This PR is quite large!"
message: "Please consider splitting this into multiple smaller PRs. Our team prefers PRs under 500 lines for better review quality."Use your own image URL:
- uses: lukasjuhas/big-diff-energy-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
image-url: "https://example.com/your-custom-image.png"Combine all options for complete control:
- uses: lukasjuhas/big-diff-energy-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
threshold: 800
title: "⚠️ Large PR detected"
message: "This PR exceeds our recommended size. Please review our [contribution guidelines](https://example.com/guidelines) for best practices."
image-url: "https://example.com/custom-warning.png"You can customize when the action runs:
on:
pull_request:
types: [opened] # Only on first open, not on updates# Clone the repo
git clone https://github.com/lukasjuhas/big-diff-energy-action.git
cd big-diff-energy-action
# Install dependencies
npm install
# Make your changes to index.jsTo test this action in your own repository:
- Reference it using a branch or commit SHA:
- uses: lukasjuhas/big-diff-energy-action@main- Create a PR with 1000+ line additions to trigger the comment
Contributions are welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit PRs with improvements
- Share feedback on the action
MIT © Lukas Juhas
Inspired by the eternal struggle of reviewing massive PRs. 🙏
