SuperAPI AI 工具集

dependabot

部署与运维

查看项目

更新于 10-15 21:52

技能介绍

Dependabot 是 GitHub 内置的依赖管理工具,包含三类能力:依赖告警(依赖存在已知漏洞时通知)、安全更新(自动创建 PR 修复有漏洞的依赖)、版本更新(自动创建 PR 保持依赖为最新)。全部配置集中在默认分支的 .github/dependabot.yml 一个文件中,GitHub 不支持每个仓库多个该文件。

配置流程:先扫描仓库识别依赖清单,确定 package-ecosystem 取值(如 npm、pip、uv、docker、github-actions、gomod、bundler、cargo、composer、nuget、maven、gradle、terraform、helm 等);再映射目录位置,通配符需用复数 directories,单数 directory 不支持 glob;每个条目至少需 package-ecosystem、directory 和 schedule.interval。

主要能力包括:用 groups 按依赖类型或名称模式分组以减少 PR 噪音,applies-to: security-updates 可分组安全更新;multi-ecosystem-groups 可跨生态合并更新,此时 patterns 为必填;group-by: dependency-name 可跨目录合并同一依赖。可自定义 labels、commit-message、assignees、milestone、target-branch、分支名分隔符。调度支持 daily、weekly、monthly、quarterly、semiannually、yearly、cron,并可设置 cooldown 延迟新版本更新(仅版本更新)。

安全更新需在仓库 Settings → Advanced Security 中启用告警与安全更新;open-pull-requests-limit: 0 可关闭版本更新仅保留安全更新。PR 评论命令包括 @dependabot rebase、recreate、ignore this dependency/major/minor/patch version,分组 PR 还支持 ignore、unignore、show 等;自 2026 年 1 月起 merge/close/reopen 命令已弃用,改用 GitHub 原生界面、gh pr merge 或自动合并。

其他选项含 ignore/allow 规则(同时匹配时以 ignore 为准)、exclude-paths、versioning-strategy、rebase-strategy、open-pull-requests-limit、私有 registries。限制:所有目录须使用同一生态;跨目录分组仅适用于版本更新;版本约束不兼容会拆分为多个 PR;设置 target-branch 时安全更新仍指向默认分支。

在 AI 编码代理中提交前扫描依赖,可启用 GitHub MCP Server 的 dependabot 工具集:copilot --add-github-mcp-toolset dependabot,或安装 advanced-security 插件后使用 /dependency-scanning。