A GitHub Action that automatically detects spammy or low-quality pull requests using rule-based heuristics and optionally flags them using labels or comments.
- Detects PRs that:
- Have very small or meaningless changes.
- Modify only documentation files.
- Have generic commit titles (like "update" or "fix").
- Lack a clear description.
- Automatically labels suspicious PRs as
spam. - Posts a comment to notify the contributor.
Add this workflow to your repository:
# .github/workflows/pr-spam-shield.yml
name: PR Spam Shield
on:
pull_request:
types: [opened, edited, reopened]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Spam Shield
run: python .github/scripts/pr_analyzer.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}