Get PR-Sentinel running in 5 minutes!
- Python 3.8+ or Docker
- GitHub Personal Access Token (Create one here)
- Required permissions:
repo(Full control of private repositories)
- Required permissions:
# 1. Clone the repository
git clone https://github.com/Anorak001/PR-Sentinel.git
cd PR-Sentinel
# 2. Install dependencies
pip install -r requirements.txt
# 3. Create configuration
cp .env.example .env
# 4. Edit .env and add your GitHub token
nano .env
# Set: GITHUB_TOKEN=your_token_here
# 5. Run the server
python main.py
# Server is now running at http://localhost:8000# 1. Clone the repository
git clone https://github.com/Anorak001/PR-Sentinel.git
cd PR-Sentinel
# 2. Create .env file
cat > .env << EOF
GITHUB_TOKEN=your_token_here
GITHUB_WEBHOOK_SECRET=your_secret_here
SPAM_SCORE_THRESHOLD=70
EOF
# 3. Start with Docker Compose
docker-compose up -d
# 4. Check logs
docker-compose logs -f
# Server is now running at http://localhost:8000# Check health
curl http://localhost:8000/health
# Expected: {"status":"healthy"}
# Check service info
curl http://localhost:8000/
# Expected: {"service":"PR-Sentinel","status":"running",...}
# Check stats
curl http://localhost:8000/stats
# Expected: {"total_tracked":0,"spam_detected":0,"recent_prs":[]}Local testing with ngrok:
# Install ngrok from https://ngrok.com/download
ngrok http 8000
# Copy the HTTPS URL (e.g., https://abc123.ngrok.io)Production:
- Use your server's public domain or IP
- Example:
https://pr-sentinel.yourdomain.com
- Go to your repository on GitHub
- Click Settings → Webhooks → Add webhook
- Fill in:
- Payload URL:
https://your-domain.com/webhook - Content type:
application/json - Secret: (Optional but recommended) Same as
GITHUB_WEBHOOK_SECRETin .env - Which events?: Select "Let me select individual events"
- ✅ Check Pull requests
- ❌ Uncheck everything else
- Active: ✅ Checked
- Payload URL:
- Click Add webhook
- Create a test PR in your repository with minimal changes
- Check PR-Sentinel logs:
# Docker docker-compose logs -f # Local # Check terminal where python main.py is running
- Check stats:
curl http://localhost:8000/stats
Edit .env:
# More lenient (fewer auto-closes)
SPAM_SCORE_THRESHOLD=80
# More strict (more aggressive)
SPAM_SCORE_THRESHOLD=60
# Default (balanced)
SPAM_SCORE_THRESHOLD=70Restart the service after changes:
# Docker
docker-compose restart
# Local
# Press Ctrl+C and run python main.py againAdd to config.py:
DRY_RUN = True # Will log actions but not actually close PRsSolution: Set GITHUB_TOKEN in .env file
Solution:
- Check that
GITHUB_WEBHOOK_SECRETmatches in both .env and GitHub webhook settings - OR remove the secret from both places (less secure but works for testing)
Solution:
# Option 1: Use different port
PORT=8080 python main.py
# Option 2: Kill process using port 8000
lsof -ti:8000 | xargs kill -9Solution:
pip install -r requirements.txtSolution:
- Make sure your server is publicly accessible
- Check firewall rules
- For local testing, use ngrok
-
Monitor Performance
- Check
/statsregularly - Review logs for false positives
- Adjust threshold if needed
- Check
-
Customize Detection
- See
CUSTOMIZATION.mdfor advanced configuration - Add custom patterns for your repository's spam
- See
-
Deploy to Production
- See
DEPLOYMENT.mdfor cloud deployment options - Use Docker for easier deployment
- Set up monitoring and alerts
- See
-
Review Documentation
README.md- Main documentationFEATURES.md- Feature detailsDEPLOYMENT.md- Deployment guidesCUSTOMIZATION.md- Customization options
- Bug Reports: Open an issue on GitHub
- Questions: Use GitHub Discussions
- Documentation: Check the docs in this repository
Create a PR with these characteristics to test spam detection:
Title: "Fix typo in README"
Body: "minor fix"
Changes: Change 1-2 lines in README.md
Expected Result:
- Spam score: ~65-75
- If threshold is 70: Should be flagged and closed
- Check logs and
/statsendpoint
# View logs (Docker)
docker-compose logs -f pr-sentinel
# Restart service (Docker)
docker-compose restart
# Stop service (Docker)
docker-compose down
# Check stats
curl http://localhost:8000/stats | python -m json.tool
# Test webhook manually
curl -X POST http://localhost:8000/webhook \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: pull_request" \
-d @test_payload.json
# Run tests
python test_spam_detector.py- Python/Docker installed
- GitHub token created and configured
- Dependencies installed
- Server running and accessible
- Health check returns OK
- GitHub webhook configured
- Test PR processed successfully
- Stats show tracked PR
- Logs show PR analysis
PR-Sentinel is now protecting your repository from spam PRs!
Monitor the /stats endpoint and logs to see it in action.