dependabot
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDependabot Configuration & Management
Dependabot 配置与管理
Overview
概述
Dependabot is GitHub's built-in dependency management tool with three core capabilities:
- Dependabot Alerts — Notify when dependencies have known vulnerabilities (CVEs)
- Dependabot Security Updates — Auto-create PRs to fix vulnerable dependencies
- Dependabot Version Updates — Auto-create PRs to keep dependencies current
All configuration lives in a single file: on the default branch. GitHub does not support multiple files per repository.
.github/dependabot.ymldependabot.ymlDependabot 是 GitHub 内置的依赖项管理工具,具有三项核心能力:
- Dependabot Alerts — 在依赖项存在已知漏洞(CVE)时发出通知
- Dependabot Security Updates — 自动创建 PR 以修复存在漏洞的依赖项
- Dependabot Version Updates — 自动创建 PR 以使依赖项保持最新
所有配置都位于默认分支上的单个文件:。GitHub 不支持每个仓库使用多个 文件。
.github/dependabot.ymldependabot.ymlConfiguration Workflow
配置工作流
Follow this process when creating or optimizing a :
dependabot.yml创建或优化 时,请遵循以下流程:
dependabot.ymlStep 1: Detect All Ecosystems
第 1 步:检测所有 package ecosystem
Scan the repository for dependency manifests. Look for:
| Ecosystem | YAML Value | Manifest Files |
|---|---|---|
| npm/pnpm/yarn | | |
| pip/pipenv/poetry | | |
| uv | | |
| Docker | | |
| Docker Compose | | |
| GitHub Actions | | |
| Go modules | | |
| Bundler (Ruby) | | |
| Cargo (Rust) | | |
| Composer (PHP) | | |
| NuGet (.NET) | | |
| .NET SDK | | |
| Maven (Java) | | |
| Gradle (Java) | | |
| Terraform | | |
| OpenTofu | | |
| Helm | | |
| Hex (Elixir) | | |
| Swift | | |
| Pub (Dart) | | |
| Bun | | |
| Dev Containers | | |
| Git Submodules | | |
| Pre-commit | | |
Notes:
- pnpm and yarn both use the ecosystem value.
npm - Prefer ecosystem value when
uvis present; otherwise useuv.lock.pip
扫描仓库中的 dependency manifest。查找:
| package ecosystem | YAML 值 | Manifest 文件 |
|---|---|---|
| npm/pnpm/yarn | | |
| pip/pipenv/poetry | | |
| uv | | |
| Docker | | |
| Docker Compose | | |
| GitHub Actions | | |
| Go modules | | |
| Bundler (Ruby) | | |
| Cargo (Rust) | | |
| Composer (PHP) | | |
| NuGet (.NET) | | |
| .NET SDK | | |
| Maven (Java) | | |
| Gradle (Java) | | |
| Terraform | | |
| OpenTofu | | |
| Helm | | |
| Hex (Elixir) | | |
| Swift | | |
| Pub (Dart) | | |
| Bun | | |
| Dev Containers | | |
| Git Submodules | | |
| Pre-commit | | |
注意:
- pnpm 和 yarn 都使用 ecosystem 值。
npm - 存在 时,优先使用
uv.lockecosystem 值;否则使用uv。pip
Step 2: Map Directory Locations
第 2 步:映射目录位置
For each ecosystem, identify where manifests live. Use (plural) with glob patterns for monorepos:
directoriesyaml
directories:
- "/" # root
- "/apps/*" # all app subdirs
- "/packages/*" # all package subdirs
- "/lib-*" # dirs starting with lib-
- "**/*" # recursive (all subdirs)Important: (singular) does NOT support globs. Use (plural) for wildcards.
directorydirectories对于每个 package ecosystem,确定 manifest 所在位置。对于 monorepo,使用带 glob 模式的 (复数):
directoriesyaml
directories:
- "/" # root
- "/apps/*" # all app subdirs
- "/packages/*" # all package subdirs
- "/lib-*" # dirs starting with lib-
- "**/*" # recursive (all subdirs)重要提示:(单数)不支持 glob。对于通配符,请使用 (复数)。
directorydirectoriesStep 3: Configure Each Ecosystem Entry
第 3 步:配置每个 ecosystem 条目
Every entry needs at minimum:
yaml
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"每个条目至少需要:
yaml
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"Step 4: Optimize with Grouping, Labels, and Scheduling
第 4 步:通过分组、标签和调度进行优化
See sections below for each optimization technique.
有关各项优化技术,请参阅以下章节。
Monorepo Strategies
Monorepo 策略
Glob Patterns for Workspace Coverage
覆盖工作区的 Glob 模式
For monorepos with many packages, use glob patterns to avoid listing each directory:
yaml
- package-ecosystem: "npm"
directories:
- "/"
- "/apps/*"
- "/packages/*"
- "/services/*"
schedule:
interval: "weekly"对于包含许多 package 的 monorepo,使用 glob 模式可以避免逐个列出目录:
yaml
- package-ecosystem: "npm"
directories:
- "/"
- "/apps/*"
- "/packages/*"
- "/services/*"
schedule:
interval: "weekly"Cross-Directory Grouping
跨目录分组
Use to create a single PR when the same dependency updates across multiple directories:
group-by: dependency-nameyaml
groups:
monorepo-deps:
group-by: dependency-nameThis creates one PR per dependency across all specified directories, reducing CI costs and review burden.
Limitations:
- All directories must use the same package ecosystem
- Applies to version updates only
- Incompatible version constraints create separate PRs
当同一依赖项在多个目录中更新时,使用 创建单个 PR:
group-by: dependency-nameyaml
groups:
monorepo-deps:
group-by: dependency-name这样,所有指定目录中的同一依赖项更新会合并为一个 PR,从而降低 CI 成本和审查负担。
限制:
- 所有目录必须使用相同的 package ecosystem
- 仅适用于版本更新
- 不兼容的版本约束会生成单独的 PR
Standalone Packages Outside Workspaces
Workspace 之外的独立 Package
If a directory has its own lockfile and is NOT part of the workspace (e.g., scripts in ), create a separate ecosystem entry for it.
.github/如果某个目录有自己的 lockfile,且不属于 workspace(例如 中的脚本),请为它创建独立的 ecosystem 条目。
.github/Dependency Grouping
依赖项分组
Reduce PR noise by grouping related dependencies into single PRs.
通过将相关依赖项分组到单个 PR 中,减少 PR 干扰。
By Dependency Type
按依赖项类型分组
yaml
groups:
dev-dependencies:
dependency-type: "development"
update-types: ["minor", "patch"]
production-dependencies:
dependency-type: "production"
update-types: ["minor", "patch"]yaml
groups:
dev-dependencies:
dependency-type: "development"
update-types: ["minor", "patch"]
production-dependencies:
dependency-type: "production"
update-types: ["minor", "patch"]By Name Pattern
按名称模式分组
yaml
groups:
angular:
patterns: ["@angular*"]
update-types: ["minor", "patch"]
testing:
patterns: ["jest*", "@testing-library*", "ts-jest"]yaml
groups:
angular:
patterns: ["@angular*"]
update-types: ["minor", "patch"]
testing:
patterns: ["jest*", "@testing-library*", "ts-jest"]For Security Updates
用于安全更新
yaml
groups:
security-patches:
applies-to: security-updates
patterns: ["*"]
update-types: ["patch", "minor"]Key behaviors:
- Dependencies matching multiple groups go to the first match
- defaults to
applies-towhen absentversion-updates - Ungrouped dependencies get individual PRs
yaml
groups:
security-patches:
applies-to: security-updates
patterns: ["*"]
update-types: ["patch", "minor"]关键行为:
- 匹配多个组的依赖项会进入第一个匹配的组
- 未指定时,默认为
applies-toversion-updates - 未分组的依赖项会各自生成一个 PR
Multi-Ecosystem Groups
多生态系统分组
Combine updates across different package ecosystems into a single PR:
yaml
version: 2
multi-ecosystem-groups:
infrastructure:
schedule:
interval: "weekly"
labels: ["infrastructure", "dependencies"]
updates:
- package-ecosystem: "docker"
directory: "/"
patterns: ["nginx", "redis"]
multi-ecosystem-group: "infrastructure"
- package-ecosystem: "terraform"
directory: "/"
patterns: ["aws*"]
multi-ecosystem-group: "infrastructure"The key is required when using .
patternsmulti-ecosystem-group将不同 package ecosystem 的更新合并到单个 PR:
yaml
version: 2
multi-ecosystem-groups:
infrastructure:
schedule:
interval: "weekly"
labels: ["infrastructure", "dependencies"]
updates:
- package-ecosystem: "docker"
directory: "/"
patterns: ["nginx", "redis"]
multi-ecosystem-group: "infrastructure"
- package-ecosystem: "terraform"
directory: "/"
patterns: ["aws*"]
multi-ecosystem-group: "infrastructure"使用 时必须设置 键。
multi-ecosystem-grouppatternsPR Customization
PR 自定义
Labels
标签
yaml
labels:
- "dependencies"
- "npm"Set to disable all labels including defaults. SemVer labels (, , ) are always applied if present in the repo.
labels: []majorminorpatchyaml
labels:
- "dependencies"
- "npm"设置 可禁用所有标签,包括默认标签。如果仓库中存在 SemVer 标签(、、),则始终应用这些标签。
labels: []majorminorpatchCommit Messages
提交消息
yaml
commit-message:
prefix: "deps"
prefix-development: "deps-dev"
include: "scope" # adds deps/deps-dev scope after prefixyaml
commit-message:
prefix: "deps"
prefix-development: "deps-dev"
include: "scope" # adds deps/deps-dev scope after prefixAssignees and Milestones
负责人和里程碑
yaml
assignees: ["security-team-lead"]
milestone: 4 # numeric ID from milestone URLyaml
assignees: ["security-team-lead"]
milestone: 4 # numeric ID from milestone URLBranch Name Separator
分支名称分隔符
yaml
pull-request-branch-name:
separator: "-" # default is /yaml
pull-request-branch-name:
separator: "-" # default is /Target Branch
目标分支
yaml
target-branch: "develop" # PRs target this instead of default branchNote: When is set, security updates still target the default branch; all ecosystem config only applies to version updates.
target-branchyaml
target-branch: "develop" # PRs target this instead of default branch注意:设置 后,安全更新仍会指向默认分支;所有 ecosystem 配置仅适用于版本更新。
target-branchSchedule Optimization
调度优化
Intervals
更新间隔
Supported: , , , , , ,
dailyweeklymonthlyquarterlysemiannuallyyearlycronyaml
schedule:
interval: "weekly"
day: "monday" # for weekly only
time: "09:00" # HH:MM format
timezone: "America/New_York"支持的间隔:、、、、、、
dailyweeklymonthlyquarterlysemiannuallyyearlycronyaml
schedule:
interval: "weekly"
day: "monday" # for weekly only
time: "09:00" # HH:MM format
timezone: "America/New_York"Cron Expressions
Cron 表达式
yaml
schedule:
interval: "cron"
cronjob: "0 9 * * 1" # Every Monday at 9 AMyaml
schedule:
interval: "cron"
cronjob: "0 9 * * 1" # Every Monday at 9 AMCooldown Periods
Cooldown 周期
Delay updates for newly released versions to avoid early-adopter issues:
yaml
cooldown:
default-days: 5
semver-major-days: 30
semver-minor-days: 7
semver-patch-days: 3
include: ["*"]
exclude: ["critical-lib"]Cooldown applies to version updates only, not security updates.
延迟新发布版本的更新,以避免早期采用者遇到问题:
yaml
cooldown:
default-days: 5
semver-major-days: 30
semver-minor-days: 7
semver-patch-days: 3
include: ["*"]
exclude: ["critical-lib"]Cooldown 仅适用于版本更新,不适用于安全更新。
Security Updates Configuration
安全更新配置
Enable via Repository Settings
通过仓库设置启用
Settings → Advanced Security → Enable Dependabot alerts, security updates, and grouped security updates.
Settings → Advanced Security → 启用 Dependabot alerts、security updates 和 grouped security updates。
Group Security Updates in YAML
在 YAML 中对安全更新进行分组
yaml
groups:
security-patches:
applies-to: security-updates
patterns: ["*"]
update-types: ["patch", "minor"]yaml
groups:
security-patches:
applies-to: security-updates
patterns: ["*"]
update-types: ["patch", "minor"]Disable Version Updates (Security Only)
禁用版本更新(仅使用安全更新)
yaml
open-pull-requests-limit: 0 # disables version update PRsyaml
open-pull-requests-limit: 0 # disables version update PRsAuto-Triage Rules
Auto-Triage 规则
GitHub presets auto-dismiss low-impact alerts for development dependencies. Custom rules can filter by severity, package name, CWE, and more. Configure in repository Settings → Advanced Security.
GitHub 预设会自动关闭开发依赖项的低影响警报。自定义规则可按严重性、软件包名称、CWE 等条件进行筛选。在仓库的 Settings → Advanced Security 中配置。
PR Comment Commands
PR 评论命令
Interact with Dependabot PRs using comments.
@dependabotNote: As of January 2026, merge/close/reopen commands have been deprecated. Use GitHub's native UI, CLI (), or auto-merge instead.gh pr merge
| Command | Effect |
|---|---|
| Rebase the PR |
| Recreate the PR from scratch |
| Close and never update this dependency |
| Ignore this major version |
| Ignore this minor version |
| Ignore this patch version |
For grouped PRs, additional commands:
- — ignore specific dependency in group
@dependabot ignore DEPENDENCY_NAME - — clear ignores, reopen with updates
@dependabot unignore DEPENDENCY_NAME - — clear all ignores for all dependencies in group
@dependabot unignore * - — display current ignores
@dependabot show DEPENDENCY_NAME ignore conditions
For the complete command reference, see .
references/pr-commands.md使用 评论与 Dependabot PR 交互。
@dependabot注意: 截至 2026 年 1 月,merge/close/reopen 命令已被弃用。 请改用 GitHub 原生 UI、CLI()或 auto-merge。gh pr merge
| 命令 | 效果 |
|---|---|
| 对 PR 执行 rebase |
| 从头重新创建 PR |
| 关闭该 PR,且此后不再更新此依赖项 |
| 忽略该 major 版本 |
| 忽略该 minor 版本 |
| 忽略该 patch 版本 |
对于分组 PR,还支持以下命令:
- — 忽略组内特定依赖项
@dependabot ignore DEPENDENCY_NAME - — 清除忽略设置,并随更新重新打开 PR
@dependabot unignore DEPENDENCY_NAME - — 清除组内所有依赖项的忽略设置
@dependabot unignore * - — 显示当前忽略条件
@dependabot show DEPENDENCY_NAME ignore conditions
有关完整的命令参考,请参阅 。
references/pr-commands.mdIgnore and Allow Rules
Ignore 和 Allow 规则
Ignore Specific Dependencies
忽略特定依赖项
yaml
ignore:
- dependency-name: "lodash"
- dependency-name: "@types/node"
update-types: ["version-update:semver-patch"]
- dependency-name: "express"
versions: ["5.x"]yaml
ignore:
- dependency-name: "lodash"
- dependency-name: "@types/node"
update-types: ["version-update:semver-patch"]
- dependency-name: "express"
versions: ["5.x"]Allow Only Specific Types
仅允许特定类型
yaml
allow:
- dependency-type: "production"
- dependency-name: "express"Rule: If a dependency matches both and , it is ignored.
allowignoreyaml
allow:
- dependency-type: "production"
- dependency-name: "express"规则:如果依赖项同时匹配 和 ,则会被忽略。
allowignoreExclude Paths
排除路径
yaml
exclude-paths:
- "vendor/**"
- "test/fixtures/**"yaml
exclude-paths:
- "vendor/**"
- "test/fixtures/**"Advanced Options
高级选项
Versioning Strategy
版本约束策略
Controls how Dependabot edits version constraints:
| Value | Behavior |
|---|---|
| Default — increase for apps, widen for libraries |
| Always increase minimum version |
| Only change if current range excludes new version |
| Only update lockfiles, ignore manifests |
| Widen range to include both old and new versions |
控制 Dependabot 如何编辑版本约束:
| 值 | 行为 |
|---|---|
| 默认——对应用提高版本约束,对库放宽版本约束 |
| 始终提高最低版本 |
| 仅当当前范围不包含新版本时才更改 |
| 仅更新 lockfile,不更新 manifest |
| 放宽范围,以同时包含旧版本和新版本 |
Rebase Strategy
Rebase 策略
yaml
rebase-strategy: "disabled" # stop auto-rebasingAllow rebase over extra commits by including in commit messages.
[dependabot skip]yaml
rebase-strategy: "disabled" # stop auto-rebasing通过在提交消息中包含 ,允许在额外提交之上执行 rebase。
[dependabot skip]Open PR Limit
打开的 PR 数量上限
yaml
open-pull-requests-limit: 10 # default is 5 for version, 10 for securitySet to to disable version updates entirely.
0yaml
open-pull-requests-limit: 10 # default is 5 for version, 10 for security版本更新的默认值为 5,安全更新的默认值为 10。
设为 可完全禁用版本更新。
0Private Registries
私有 Registry
yaml
registries:
npm-private:
type: npm-registry
url: https://npm.example.com
token: ${{secrets.NPM_TOKEN}}
updates:
- package-ecosystem: "npm"
directory: "/"
registries:
- npm-privateyaml
registries:
npm-private:
type: npm-registry
url: https://npm.example.com
token: ${{secrets.NPM_TOKEN}}
updates:
- package-ecosystem: "npm"
directory: "/"
registries:
- npm-privateFAQ
FAQ
Can I have multiple files?
No. GitHub supports exactly one file at . Use multiple entries within that file for different ecosystems and directories.
dependabot.yml.github/dependabot.ymlupdatesDoes Dependabot support pnpm?
Yes. Use — Dependabot detects automatically.
package-ecosystem: "npm"pnpm-lock.yamlHow do I reduce PR noise in a monorepo?
Use to batch updates, with globs for coverage, and for cross-directory grouping. Consider or intervals for low-priority ecosystems.
groupsdirectoriesgroup-by: dependency-namemonthlyquarterlyHow do I handle dependencies outside the workspace?
Create a separate ecosystem entry with its own pointing to that location.
directory我能有多个 文件吗?
不能。GitHub 仅支持在 放置一个文件。对于不同的 package ecosystem 和目录,请在该文件内使用多个 条目。
dependabot.yml.github/dependabot.ymlupdatesDependabot 支持 pnpm 吗?
支持。使用 即可——Dependabot 会自动检测 。
package-ecosystem: "npm"pnpm-lock.yaml如何减少 monorepo 中的 PR 干扰?
使用 批量处理更新,使用带 glob 的 覆盖工作区,并使用 进行跨目录分组。对于低优先级 ecosystem,可以考虑使用 或 间隔。
groupsdirectoriesgroup-by: dependency-namemonthlyquarterly如何处理 workspace 之外的依赖项?
创建一个独立的 ecosystem 条目,并使用指向该位置的 。
directoryPre-Commit Dependency Scanning via AI Coding Agents
通过 AI 编程 Agent 进行 Pre-Commit 依赖项扫描
For scanning code changes for vulnerable dependencies inside an AI coding agent before committing, the GitHub MCP Server's toolset can check your dependency additions against the GitHub Advisory Database and return structured results with affected packages, severity, and recommended fixed versions. For more thorough post-commit checks, it can also run the Dependabot CLI locally to diff dependency graphs before and after your changes.
dependabotInstall the Advanced Security plugin which provides dedicated dependency scanning tools and the skill.
/dependency-scanningGitHub Copilot CLI (shell):
bash
undefined若要在提交前通过 AI 编程 Agent 扫描代码变更中的漏洞依赖项,GitHub MCP Server 的 toolset 可以根据 GitHub Advisory Database 检查新增的依赖项,并返回结构化结果,其中包含受影响的软件包、严重性以及建议修复版本。对于更全面的提交后检查,它还可以在本地运行 Dependabot CLI,对比更改前后的 dependency graph。
dependabot安装 Advanced Security plugin,该 plugin 提供专用的依赖项扫描工具和 skill。
/dependency-scanningGitHub Copilot CLI(shell):
bash
undefinedEnable the dependabot toolset for the GitHub MCP Server
Enable the dependabot toolset for the GitHub MCP Server
copilot --add-github-mcp-toolset dependabot
**GitHub Copilot CLI (inside `copilot`):**
```text
> /plugin install advanced-security@copilot-pluginsVisual Studio Code:
- Add to your GitHub MCP Server headers, or pick Dependabot from the toolset selector in Copilot Chat
"X-MCP-Toolsets": "dependabot" - Install the plugin, then use
advanced-securityin Copilot Chat/dependency-scanning
Example prompt:
Scan the dependencies I added on this branch for known vulnerabilities and tell me which versions to upgrade to before I commit.
Announced in Dependency scanning with GitHub MCP Server is in public preview (May 2026)
copilot --add-github-mcp-toolset dependabot
**GitHub Copilot CLI(在 `copilot` 中):**
```text
> /plugin install advanced-security@copilot-pluginsVisual Studio Code:
- 将 添加到 GitHub MCP Server 请求头中,或者在 Copilot Chat 的 toolset selector 中选择 Dependabot
"X-MCP-Toolsets": "dependabot" - 安装 plugin,然后在 Copilot Chat 中使用
advanced-security/dependency-scanning
示例提示词:
请扫描我在此分支上添加的依赖项,找出已知漏洞,并告诉我提交前应升级到哪些版本。
公布于 通过 GitHub MCP Server 进行依赖项扫描现已公开预览(2026 年 5 月)
Resources
资源
- — Complete YAML options reference
references/dependabot-yml-reference.md - — Full PR comment commands reference
references/pr-commands.md - — Real-world configuration examples
references/example-configs.md
- — 完整的 YAML 选项参考
references/dependabot-yml-reference.md - — 完整的 PR 评论命令参考
references/pr-commands.md - — 实际配置示例
references/example-configs.md