Dependabot auto-merge strategy
This document explains AlignTrue’s hybrid approach to automatically merging Dependabot PRs.
Overview
Goal: Save maintainer time on routine dependency updates while preserving manual review for higher-risk changes.
Strategy (matches the workflow logic):
- Auto-merge when the PR is from Dependabot and:
- Labeled
devDependencies, or - Detected as a security patch, or
- Title includes
patch/fromand the PR is not labeledrequires-review
- Labeled
- Manual review for PRs labeled
requires-reviewor anything without a safe signal
Configuration
1. .github/dependabot.yml
Dependabot is configured to:
- Create separate PRs per directory (workspace isolation)
- Label PRs by scope (devDependencies, schema, cli, web, docs, etc.)
- Group updates by risk (dev vs production)
- Ignore unsafe updates (e.g., Next.js major versions)
Key scopes:
- Root
/: dev-dependencies only → auto-merge safe (labeleddevDependencies) - Packages (
/packages/schema,/packages/cli,/packages/mcp): patch/minor only → auto-merge safe (norequires-reviewlabel applied) - Web app (
/apps/web): dev deps auto-merge; production deps labeledrequires-review→ manual - Docs app (
/apps/docs): dev deps auto-merge; production deps labeledrequires-review→ manual
2. .github/workflows/dependabot-auto-merge.yml
GitHub Actions workflow that:
- Detects all Dependabot PRs
- Checks if PR is labeled as “safe” (
devDependencies, security, or title includespatch/fromwithoutrequires-review) - Auto-approves safe PRs with rationale
- Waits for CI to pass (max 10 minutes)
- Enables GitHub’s auto-merge (squash strategy)
- Leaves unsafe PRs pending for manual review
Trigger: Runs on all pull requests to main
Conditions:
- Only acts on PRs from
dependabot[bot] - Requires passing CI checks before merge
- Uses squash merge to keep commit history clean
What gets auto-merged
✅ Automatically merged once CI passes (safe signals):
- Any PR with
devDependencieslabel (all scopes) - PRs Dependabot marks as security patches (label or body text)
- PR titles containing
patch/fromwithoutrequires-reviewlabel (covers patch/minor in scoped packages; majors would only pass if norequires-reviewlabel is applied)
Note: The workflow does not explicitly parse minor updates; Dependabot titles include from, so the title check covers patch/minor (and majors if a requires-review label is missing).
❌ Requires manual review (no safe signal):
- PRs labeled
requires-review(runtime deps for web/docs, or other scopes you opt in) - Any PR missing a safe signal (e.g., custom scopes without
devDependencieslabel) - Security patches still auto-approve/merge unless you remove that behavior
What to watch for
-
CI failures: If a Dependabot PR fails CI, auto-merge is blocked. Review the error and decide:
- Is it a real incompatibility? → Manual fix or manual rejection
- Is it a flaky test? → Re-run CI or merge manually
-
Security patches: Auto-merged at all severity levels. The approval comment will clearly identify them:
- Look for
🔒 Auto-approved: Security patchin the PR comment - Verify CI tests pass (they’re gated behind full CI run)
- Merged via squash merge for clean history
- Look for
-
Label coverage: Manual review depends on
requires-reviewlabels. If you add new production scopes, ensure Dependabot appliesrequires-reviewor restricts update types; otherwise majors could be treated as safe due to the title check. -
Monorepo balance: Web and docs apps have both auto-merge and manual-review rules to balance safety with developer experience.
Performance impact
- Devs: Zero overhead. PRs auto-merge while you work on other things.
- CI: One full test run per Dependabot PR. Runs on Linux + Windows per
.github/workflows/ci.yml. - Review time: ~0 seconds for safe updates, on-demand for risky ones.
Disabling auto-merge
To temporarily disable auto-merge or change the strategy:
- Disable entirely: Comment out the
dependabot-auto-merge.ymlworkflow - Change scopes: Edit
.github/dependabot.ymllabels and allow/ignore rules - Change merge method: Update
dependabot-auto-merge.ymlto usemergeorrebaseinstead ofsquash
Testing the setup
Automatic testing
After pushing these files, the workflow starts on next pull request:
- Wait for a new Dependabot PR to arrive (weekly on Mondays)
- Check the PR for:
- Expected labels (e.g.,
devDependencies,cli,requires-review,security) - Auto-approval comment from the workflow with reasoning
- Auto-merge badge once CI passes
- Expected labels (e.g.,
- Monitor GitHub Actions to see the workflow logs
Testing security patch behavior
To verify security patch auto-merge works:
- Check a recent security alert: Visit https://github.com/AlignTrue/aligntrue/security/dependabot
- Wait for next Dependabot run (Mondays, or trigger manually with
gh workflow run) - Look for security-specific comment: If Dependabot creates a PR with “security” label or “Dependabot security update” in body, the workflow will:
- Show
🔒 Auto-approved: Security patchcomment - Run full CI (Linux + Windows)
- Auto-merge once CI passes
- Show
- Validate in GitHub Actions: Check
.github/workflows/dependabot-auto-merge.ymllogs to see security detection logic
Testing manual-review coverage
To confirm majors and other risky updates stay manual:
- Create or wait for a PR in a scope that should require review (e.g.,
apps/webruntime deps). - Verify the PR has
requires-reviewlabel. - Confirm the workflow does not auto-approve and leaves the PR pending review.