Automatically detect and label potential spam pull requests to keep your repository clean and maintainable.
Open source repositories often face challenges with:
- Spam PRs: Low-quality pull requests with minimal changes (like single character edits) that clutter your repository
- Time-consuming manual review: Maintainers spend valuable time identifying and triaging small, potentially spam contributions
- Repository noise: Legitimate contributions get buried under a flood of minimal-effort PRs
- Inconsistent labeling: Manual labeling of suspicious PRs is time-consuming and prone to human oversight
AntiSpamPRLabeler solves this by automatically identifying and labeling pull requests with suspiciously small changes, helping maintainers focus on meaningful contributions.
This GitHub Action automatically:
- 🏷️ Labels pull requests as "Potential Spam" when they contain fewer changes than your specified threshold
- 💬 Comments on flagged PRs to notify contributors about the automatic labeling
- ⚡ Saves time by instantly identifying PRs that need closer review
- 🔧 Customizable thresholds and messages to fit your project's needs
Perfect for maintaining clean, high-quality repositories with minimal manual effort!
First, ensure your repository has the correct permissions:
- Go to your repository's Settings → Actions → General
- Under Workflow permissions, select Read and write permissions
- Click Save
💡 This allows the action to add labels and comments to pull requests.
Create or update your workflow file (e.g., .github/workflows/antispam-pr-labeler.yml):
name: Anti-Spam PR Labeler
on: [pull_request]
jobs:
label-spam-prs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Label Potential Spam PRs
uses: PraiseXI/AntiSpamPRLabeler@v1.2.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
max-changes-for-label: '2' # Flag PRs with 2 or fewer changes
label-message: 'This PR has been flagged for review due to minimal changes. Please ensure your contribution adds meaningful value.'That's it! 🎉 Your repository now automatically detects potential spam PRs.
| Input | Required | Default | Description |
|---|---|---|---|
repo-token |
✅ Yes | - | GitHub token for API access. Use ${{ secrets.GITHUB_TOKEN }} |
max-changes-for-label |
❌ No | 2 |
Maximum number of changes before labeling as spam |
label-message |
❌ No | Default message | Custom comment message for flagged PRs |
1: Very strict - flags single-character changes2: Balanced - catches most spam while allowing small legitimate fixes5: Lenient - only flags extremely minimal changes
Here's a full workflow with custom configuration:
name: Automate PR Quality Control
on: [pull_request]
jobs:
quality-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Anti-Spam PR Detection
uses: PraiseXI/AntiSpamPRLabeler@v1.2.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
max-changes-for-label: '3'
label-message: |
🤖 **Automated Review Notice**
This PR has been automatically flagged due to minimal changes.
If this is a legitimate contribution:
- Please ensure your changes add meaningful value
- Consider combining multiple small fixes into a single PR
- Add a detailed description explaining the necessity of the change
Thank you for contributing! 🙏- Trigger: Action runs when a pull request is opened or updated
- Analysis: Counts the total number of changes (additions + deletions)
- Decision: Compares against your configured threshold
- Action: If below threshold → adds "Potential Spam" label + comment
- Result: Maintainers can quickly identify PRs needing closer review
Check out a live example in our test repository to see how the action labels and comments on pull requests.
We welcome contributions to make AntiSpamPRLabeler even better!
- 🐛 Found a bug? Open an issue
- 💡 Have an idea? Start a discussion
- 🔧 Want to contribute code? Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the open source community