dependabot

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Dependabot

Dependabot

Dependabot creates pull requests to keep your dependencies secure and up-to-date. It is integrated natively into GitHub.
Dependabot 会创建拉取请求(PR),帮助你保持依赖项的安全与最新。它是GitHub的原生集成功能。

When to Use

使用场景

  • GitHub Repos: It's the default, easiest choice.
  • Security Patches: "Dependabot alert: Critical severity in lodash".
  • Keeping deps fresh: Automated weekly version bumps.
  • GitHub 仓库:这是默认且最简单的选择。
  • 安全补丁:比如收到“Dependabot 警报:lodash 中存在严重安全漏洞”时。
  • 保持依赖项更新:每周自动进行版本升级。

Quick Start (
dependabot.yml
)

快速开始(
dependabot.yml

yaml
undefined
yaml
undefined

.github/dependabot.yml

.github/dependabot.yml

version: 2 updates:
  • package-ecosystem: "npm" directory: "/" schedule: interval: "weekly"

    Grouping (2025 feature) reduces noise

    groups: dependencies: patterns: - "*"
undefined
version: 2 updates:
  • package-ecosystem: "npm" directory: "/" schedule: interval: "weekly"

    分组功能(2025年新特性)可减少冗余信息

    groups: dependencies: patterns: - "*"
undefined

Core Concepts

核心概念

Security Updates

安全更新

Triggered automatically when GitHub detects a vulnerability in your dependencies (via Dependency Graph). These are distinct from Version Updates.
当GitHub通过依赖关系图检测到你的依赖项存在漏洞时,会自动触发安全更新。这类更新与版本更新是分开的。

Version Updates

版本更新

Scheduled updates (Daily/Weekly) to newer versions, regardless of vulnerabilities. Driven by
dependabot.yml
.
按计划(每日/每周)更新到新版本,无论是否存在漏洞。由
dependabot.yml
配置驱动。

Grouped Updates

分组更新

Combining multiple package updates into a single PR (e.g., "Bump 5 dependencies"). Drastically reduces PR noise.
将多个包的更新合并到单个PR中(例如:“升级5个依赖项”),大幅减少PR的冗余数量。

Best Practices (2025)

最佳实践(2025年)

Do:
  • Enable Grouping: Group non-critical updates to avoid "PR Fatigue".
  • Auto-Merge (safely): If tests pass and it's a minor/patch update, configure auto-merge to reduce manual review toil.
  • Check Compatibility Scores: GitHub shows "% of CI runs that passed" for an update. Trust the crowd usage data.
Don't:
  • Don't ignore Alerts: A critical alert usually means an exploit exists.
  • Don't blindly merge Major versions: They usually contain breaking changes.
建议
  • 启用分组功能:将非关键更新分组,避免“PR疲劳”。
  • 安全自动合并:如果测试通过且是小版本/补丁版本更新,配置自动合并以减少人工审核工作量。
  • 查看兼容性评分:GitHub会显示该更新的“CI运行通过率”,可以参考大众使用数据。
不建议
  • 不要忽略警报:严重警报通常意味着已有漏洞利用方式存在。
  • 不要盲目合并大版本更新:大版本通常包含破坏性变更。

Troubleshooting

故障排查

ErrorCauseSolution
No PRs created
Config error or no updates needed.Check "Dependabot" tab in Insights -> Dependency Graph.
Merge Conflicts
Lockfile out of sync.Rebase the PR (
@dependabot rebase
).
错误信息原因解决方案
No PRs created
配置错误或无需更新。查看Insights -> Dependency Graph中的“Dependabot”标签页。
Merge Conflicts
锁定文件不同步。重新定基PR(使用
@dependabot rebase
)。

References

参考资料