管理仓库的 Dependabot security updates
可以为个人帐户或组织拥有的所有合格的存储库启用或禁用 Dependabot security updates。 有关详细信息,请参阅“管理安全和分析功能”或“管理组织的安全和分析设置”。
也可以为单个存储库启用或禁用 Dependabot security updates。
对单个仓库启用或禁用 Dependabot security updates
-
在 GitHub 上,导航到存储库的主页面。
-
在仓库名称下,单击 “Settings”****。 如果看不到“设置”选项卡,请选择“”下拉菜单,然后单击“设置”。

-
在边栏的“Security”部分中,单击“ Advanced Security”****。
-
在“Dependabot security updates”的右侧,单击“Enable”以启用该功能,或单击“Disable”予以禁用********。 对于公共存储库,如果始终启用该功能,则该按钮将被禁用。
将 Dependabot security updates 分组到单个拉取请求
若要使用分组的安全更新,你必须先启用以下功能:
-
**依赖项关系图**。 有关详细信息,请参阅“[AUTOTITLE](/code-security/supply-chain-security/understanding-your-software-supply-chain/configuring-the-dependency-graph)”。 -
**Dependabot alerts**。 有关详细信息,请参阅“[AUTOTITLE](/code-security/dependabot/dependabot-alerts/configuring-dependabot-alerts)”。 -
**Dependabot security updates**。 有关详细信息,请参阅“[AUTOTITLE](/code-security/dependabot/dependabot-security-updates/configuring-dependabot-security-updates)”。
注意
首次启用分组的安全更新后,Dependabot 将立即尝试创建分组的拉取请求。 你可能会注意到 Dependabot 在关闭旧拉取请求并打开新的拉取请求。
可以通过以下一种或两种方式为 Dependabot security updates 启用分组拉取请求。
- 若要跨目录和按生态系统将尽可能多的可用安全更新分组在一起,请在仓库的“Advanced Security”设置中,或在组织的“ Advanced Security”下的“Global settings”中启用分组。
- 如需更精细地控制分组(例如按包名称、开发/生产依赖项、SemVer 级别或每个生态系统的多个目录进行分组),请在仓库中的
dependabot.yml配置文件中添加配置选项。
注意
如果已在 dependabot.yml 文件中为 Dependabot security updates 配置了组规则,则所有可用更新都将根据指定的规则进行分组。 如果还启用了组织或存储库级别的分组安全更新设置,则 Dependabot 只会跨那些未在 dependabot.yml 中配置的目录进行分组。
对单个存储库启用或禁用分组的 Dependabot security updates
-
在 GitHub 上,导航到存储库的主页面。
-
在仓库名称下,单击 “Settings”****。 如果看不到“设置”选项卡,请选择“”下拉菜单,然后单击“设置”。

-
在边栏的“Security”部分中,单击“ Advanced Security”****。
-
在“Dependabot”下的“Grouped security updates”右侧,单击“Enable”以启用该功能,或单击“Disable”予以禁用********。
对组织启用或禁用分组的 Dependabot security updates
你可以允许将 Dependabot security updates 分组成单个拉取请求。 有关详细信息,请参阅“配置组织的全局安全设置”。
使用配置文件重写默认行为
可以通过将 dependabot.yml 文件添加到存储库来重写 Dependabot security updates 的默认行为。 使用 dependabot.yml 文件可以更精细地控制分组,并替代 Dependabot security updates 设置的默认行为。
将 groups 选项与 applies-to: security-updates 键一起使用以创建依赖项集(按包管理器),以便 Dependabot 打开单个拉取请求以同时更新多个依赖项。 可以按包名称(patterns 和 exclude-patterns 密钥)、依赖项类型(dependency-type 密钥)和 SemVer(update-types 密钥)来定义组。
Dependabot 按组在 dependabot.yml 文件中出现的顺序创建组。 如果依赖项更新可以属于多个组,则只会将它分配给与之匹配的第一个组。
如果只需要_安全_更新并且想要排除_版本_更新,可以将 open-pull-requests-limit 设置为 0,以防止给定 package-ecosystem 的版本更新。
有关可用于安全更新的配置选项的详细信息,请参阅 自定义 Dependabot 安全更新的拉取请求。
# Example configuration file that:
# - Has a private registry
# - Ignores lodash dependency
# - Disables version-updates
# - Defines a group by package name, for security updates for golang dependencies
version: 2
registries:
example:
type: npm-registry
url: https://example.com
token: ${{secrets.NPM_TOKEN}}
updates:
- package-ecosystem: "npm"
directory: "/src/npm-project"
schedule:
interval: "daily"
# For Lodash, ignore all updates
ignore:
- dependency-name: "lodash"
# Disable version updates for npm dependencies
open-pull-requests-limit: 0
registries:
- example
- package-ecosystem: "gomod"
groups:
golang:
applies-to: security-updates
patterns:
- "golang.org*"
# Example configuration file that:
# - Has a private registry
# - Ignores lodash dependency
# - Disables version-updates
# - Defines a group by package name, for security updates for golang dependencies
version: 2
registries:
example:
type: npm-registry
url: https://example.com
token: ${{secrets.NPM_TOKEN}}
updates:
- package-ecosystem: "npm"
directory: "/src/npm-project"
schedule:
interval: "daily"
# For Lodash, ignore all updates
ignore:
- dependency-name: "lodash"
# Disable version updates for npm dependencies
open-pull-requests-limit: 0
registries:
- example
- package-ecosystem: "gomod"
groups:
golang:
applies-to: security-updates
patterns:
- "golang.org*"
注意
为了让 Dependabot 将此配置用于安全更新,directory 必须是清单文件的路径,并且你不应指定 target-branch。
延伸阅读
-
[AUTOTITLE](/code-security/dependabot/dependabot-alerts/about-dependabot-alerts) -
[AUTOTITLE](/code-security/dependabot/dependabot-alerts/configuring-dependabot-alerts) -
[AUTOTITLE](/code-security/supply-chain-security/understanding-your-software-supply-chain/dependency-graph-supported-package-ecosystems#supported-package-ecosystems)