Automated merge protection with smart dependency management for TeamCity users
This package provides production-ready Mergify configuration that:
- ✅ Integrates with TeamCity - Reads TeamCity build status to auto-merge PRs
- ✅ Automates Renovate/Bolt - Patches merge without approval, majors need review
- ✅ Enforces quality - 2 approvals for main, all checks must pass
- ✅ Saves time - Auto-labels, auto-assigns teams, auto-deletes branches
- ✅ Stays safe - WIP protection, security reviews, linear history required
- ✅ Works on Windows - PowerShell scripts included
|
🪟 Windows User? Start here: WINDOWS-SETUP.md Then: QUICKSTART.md |
🐧 macOS/Linux User? Start here: QUICKSTART.md Or: START-HERE.md |
|
🔧 Need TeamCity Setup? Complete guide: TEAMCITY-SETUP.md |
🤖 Using Renovate/Bolt? Integration guide: RENOVATE-BOLT-GUIDE.md |
# 1. Copy files to your repo
Copy-Item -Recurse /path/to/package/* /your/repo/
# 2. Customize .mergify.yml
notepad .mergify.yml # Update team names, check names
# 3. Configure TeamCity
# Add "Commit Status Publisher" in TeamCity build features
# 4. Test locally
.\test-mergify.ps1
# 5. Deploy!
git add . && git commit -m "Add Mergify" && git push.mergify.yml → Main Mergify configuration (TeamCity-ready)
.teamcity/settings.kts → TeamCity Kotlin DSL examples
test-mergify.ps1 → PowerShell validation script
START-HERE.md → 📍 Complete overview & file index
WINDOWS-SETUP.md → 🪟 Windows/PowerShell setup guide
TEAMCITY-SETUP.md → 🔧 TeamCity integration (detailed)
RENOVATE-BOLT-GUIDE.md → 🤖 Renovate/Bolt automation
QUICKSTART.md → ⚡ Fast setup checklist
QUICK-REFERENCE.md → 📄 One-page cheat sheet (print this!)
TEAMCITY-UPDATE-SUMMARY.md → What changed for TeamCity
POWERSHELL-UPDATE.md → What changed for PowerShell
INDEX.md → Complete file directory
.github/scripts/test-mergify-rules.js → Node.js tests
.github/scripts/check-mergify-best-practices.py → Python checks
package.json.example → NPM scripts
.eslintrc.json.example → ESLint config
.prettierrc.example → Prettier config
| Branch | Approvals | CI Checks | Auto-Merge |
|---|---|---|---|
| main | 2 | TeamCity | After approvals |
| hotfix | 1 | TeamCity | Expedited |
| develop | 1 | TeamCity | After approval |
| Update Type | Example | Approval Required? | Auto-Merge? | Speed |
|---|---|---|---|---|
| Patch | 1.2.3 → 1.2.4 | ❌ No | ✅ Yes | ~5 min |
| Security | Any [SECURITY] |
❌ No | ✅ Yes | ~5 min |
| Minor | 1.2.3 → 1.3.0 | ✅ 1 approval | ✅ Yes | ~5 min + review |
| Major | 1.2.3 → 2.0.0 | ✅ 1 approval + review | ✅ Yes | Variable |
Result: Patch updates merge in ~5 minutes with zero human interaction! 🎉
Every PR gets labeled automatically:
backend/frontend/documentation(by file changes)dependencies+patch-update/minor-update/major-update(for deps)large-pr(20+ files changed)security-review(auth-related changes)
backend/ changes → @backend-team
frontend/ changes → @frontend-team
auth/ changes → @security-team- ✅ Draft PRs blocked from merge
- ✅
work-in-progresslabel blocks merge - ✅
do-not-mergelabel blocks merge - ✅ Changes requested blocks merge
- ✅ Linear history required (no merge commits)
- ✅ Stale reviews dismissed on new commits
- ✅ Auto-delete branches after merge
Developer creates PR
↓
TeamCity triggers builds
↓
TeamCity Commit Status Publisher
↓
GitHub shows "TeamCity" check
↓
Mergify reads check status
↓
All conditions met? → Auto-merge!
- TeamCity: Build Configuration → Build Features
- Add: "Commit Status Publisher"
- Select: GitHub
- Configure: Personal access token (needs
repo:status) - Add VCS Trigger: Branch filter
+:pull/*
Detailed instructions: TEAMCITY-SETUP.md
The default configuration uses:
check-success=TeamCityThis works with TeamCity's default status reporting. To find your exact check names:
- Create a test PR
- Look at the "Checks" tab
- Copy the exact name shown
- Update
.mergify.yml
See: TEAMCITY-SETUP.md for details
Renovate/Bolt creates PR
↓
Is it a PATCH update? ──Yes──→ Auto-approved & merged (~5 min)
│
No
↓
Is it a MINOR update? ──Yes──→ Needs 1 approval → Auto-merged
│
No
↓
Is it a MAJOR update? ──Yes──→ Needs 1 approval + review → Auto-merged
All dependency PRs automatically get labeled:
dependencies(all updates)patch-update/minor-update/major-update
This makes it easy to:
- Filter PRs by update type
- Set up custom notifications
- Track dependency health
Complete guide: RENOVATE-BOLT-GUIDE.md
This package is fully compatible with Windows using PowerShell scripts!
# 1. Enable script execution (run as Administrator)
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
# 2. Install dependencies
pip install yamllint mergify-cli pyyaml
npm install -g js-yaml
# 3. Run validation
.\test-mergify.ps1Full guide: WINDOWS-SETUP.md
- ✅ Color-coded output (green/red/yellow/blue)
- ✅ Comprehensive error messages
- ✅ Dependency verification
- ✅ Works on Windows, macOS, Linux (with PowerShell 7+)
# Run all checks
.\test-mergify.ps1This validates:
- ✅ YAML syntax
- ✅ Mergify configuration
- ✅ Rule structure (10+ tests)
- ✅ Best practices (14+ checks)
- ✅ Security scan
- Rule names are unique
- All rules have conditions and actions
- Queue configuration is valid
- No conflicting conditions
- Required checks are consistent
- Security patterns detected
- No sensitive data in config
Before deploying, update .mergify.yml:
# Find and replace:
backend-team → your-backend-team
frontend-team → your-frontend-team
security-team → your-security-team# Update to match your TeamCity status:
check-success=TeamCity # Default
# Or specific:
check-success=TeamCity: Tests
check-success=TeamCity: Lint# If not using 'main':
base=main → base=master # or your default branch# Update paths to match your structure:
^backend/ → ^src/backend/
^frontend/ → ^src/frontend/
^docs/ → ^documentation/Require 3 approvals:
- "#approved-reviews-by>=3" # Instead of >=2Add custom label:
- name: Label database changes
conditions:
- files~=^database/
actions:
label:
add:
- databaseDisable patch auto-merge:
# Comment out or remove the "Auto-merge Renovate patch updates" ruleAdd notification:
- name: Notify on major updates
conditions:
- label=major-update
actions:
comment:
message: "@team Major dependency update needs review!"Cause: Commit Status Publisher not configured
Solution:
- TeamCity → Build Configuration → Build Features
- Add "Commit Status Publisher"
- Select GitHub and add token
Cause: Check name mismatch
Solution:
- Look at GitHub PR → Checks tab
- Note exact name (case-sensitive!)
- Update
.mergify.ymlwith exact name
Cause: Script execution disabled
Solution:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserCause: VCS trigger not configured
Solution:
- TeamCity → Triggers → Add VCS Trigger
- Set branch filter:
+:pull/* - Ensure branch spec includes:
+:refs/pull/*/head
More solutions: Each guide has a troubleshooting section
- 📍 START-HERE.md - Complete overview (start here!)
- ⚡ QUICKSTART.md - Fast setup checklist
- 🪟 WINDOWS-SETUP.md - Windows/PowerShell guide
- 🔧 TEAMCITY-SETUP.md - TeamCity integration (detailed)
- 🤖 RENOVATE-BOLT-GUIDE.md - Renovate/Bolt automation
- 📄 QUICK-REFERENCE.md - One-page cheat sheet
- 📖 INDEX.md - Complete file directory
- 🔄 TEAMCITY-UPDATE-SUMMARY.md - TeamCity changes
- 🔄 RENOVATE-UPDATE-SUMMARY.md - Renovate changes
- 🔄 POWERSHELL-UPDATE.md - PowerShell changes
1. Renovate creates PR: "fix(deps): update lodash to v4.17.22 [SECURITY]"
↓
2. TeamCity runs tests (5 min)
↓
3. TeamCity reports success to GitHub
↓
4. Mergify auto-approves (patch update)
↓
5. Mergify adds labels: dependencies, patch-update
↓
6. Mergify merges to queue
↓
7. PR merged, branch deleted
Total time: ~5 minutes, ZERO human interaction! 🎉
1. Developer creates PR
↓
2. Mergify labels: backend, large-pr
↓
3. Mergify requests: @backend-team review
↓
4. TeamCity runs tests
↓
5. Reviewer 1 approves
↓
6. Reviewer 2 approves
↓
7. TeamCity passes
↓
8. Mergify auto-merges
↓
9. Branch auto-deleted
Total time: ~10 min + review time
- ✅ No hardcoded secrets (security scan included)
- ✅ Auth changes require security team review
- ✅ All PRs require CI checks to pass
- ✅ Approved by default for docs only (safe)
The validation script checks for:
- Hardcoded passwords
- API keys
- Tokens
- Secret patterns
Run: .\test-mergify.ps1
# 1. Test locally
.\test-mergify.ps1
# 2. Verify all checks pass
# If any fail, fix issues
# 3. Commit and push
git add .mergify.yml
git commit -m "Update Mergify config"
git push- Create feature branch
- Make changes to
.mergify.yml - Test locally
- Push and create PR
- TeamCity will validate
- Get required approvals
- Mergify auto-merges!
- Start simple - Use
check-success=TeamCityinitially - Test first - Always run
.\test-mergify.ps1before pushing - Monitor queue - Check Mergify dashboard weekly
- Keep builds fast - Target <10 min for CI
- Review majors - Major dependency updates need attention
- Use labels - Labels help organize and filter PRs
- Trust patches - If tests pass, patches are safe
- Document exceptions - Add comments for custom rules
https://dashboard.mergify.com/github/<your-org>/<your-repo>
View:
- Merge queue status
- Rule evaluations
- Auto-merge history
- Performance metrics
# View all dependency PRs
gh pr list --label dependencies
# View PRs needing approval
gh pr list --label minor-update
gh pr list --label major-update
# View recent auto-merges
gh pr list --state merged --author renovate[bot] --limit 20
# Check TeamCity status
gh api repos/OWNER/REPO/commits/SHA/status- Read START-HERE.md or QUICKSTART.md
- Install dependencies (Python, Node.js)
- Copy files to your repository
- Customize
.mergify.yml(teams, checks, paths) - Configure TeamCity Commit Status Publisher
- Test locally:
.\test-mergify.ps1 - Push to repository
- Create test PR
- Verify TeamCity triggers
- Verify Mergify recognizes checks
- Watch the automation! ✨
- 💬 Check the troubleshooting sections in each guide
- 📖 Review TEAMCITY-SETUP.md for integration help
- 🐛 Issues with Windows? See WINDOWS-SETUP.md
- 🤖 Dependency automation? See RENOVATE-BOLT-GUIDE.md
Use freely in your projects! This configuration is provided as-is for your use.
This package integrates:
- Mergify - Merge automation
- TeamCity - CI/CD
- Renovate - Dependency updates
- Mend Bolt - Dependency updates
After deploying this package:
✨ Automated dependency merges (patches merge without approval!) 🔒 Strong merge protections (2 approvals + all checks) 🤖 Smart bot handling (Renovate & Bolt fully automated) 👥 Team-based reviews (auto-assign by file changes) 🏷️ Automatic labeling (organize PRs automatically) ⚡ Fast iteration (merge queue with speculative checks) 📊 Full visibility (Mergify dashboard + GitHub insights) 🪟 Windows support (PowerShell scripts included)
Ready to automate your workflow? Start with START-HERE.md! 🚀
Get Started • Windows Setup • TeamCity Guide • Quick Reference
Made with ❤️ for teams who value automation