Skip to main content

为 Dependabot 配置多生态系统更新

通过将多个生态系统的更新综合到一个拉取请求中,减少 Dependabot 拉取请求的数量。

谁可以使用此功能?

Users with write access

利用多生态系统更新,可以将 Dependabot 跨不同的包生态系统拉取请求合并到每个组的单个 PR 中。 请参阅“多生态系统更新”。

先决条件

1.在 .github/dependabot.yml 文件中定义多生态系统组

在顶层 multi-ecosystem-groups 部分中,首先定义一个有时间表的组:

YAML
version: 2

multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"

updates:
  # Your existing package ecosystems will go here

2. 将生态系统分配给组

multi-ecosystem-groups 密钥和模式添加到包生态系统配置。

YAML
version: 2

multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"

updates:
  - package-ecosystem: "docker"
    directory: "/"
    patterns: ["nginx", "redis", "postgres"]
    multi-ecosystem-group: "infrastructure"

  - package-ecosystem: "terraform"
    directory: "/"
    patterns: ["aws", "terraform-*"]
    multi-ecosystem-group: "infrastructure"

注意

使用 ["*"] 来包含所有依赖项。

3.提交更改

将更改提交到 dependabot.yml 文件。

4.使用其他键进行自定义(可选)

可以将标签、审阅者或其他配置选项添加到多生态系统组。 请参阅 assigneeslabels

YAML
multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"
    assignees: ["@platform-team"]
    labels: ["infrastructure", "dependencies"]

updates:
  - package-ecosystem: "docker"
    directory: "/"
    patterns: ["nginx", "redis", "postgres"]
    multi-ecosystem-group: "infrastructure"

  - package-ecosystem: "terraform"
    directory: "/"
    patterns: ["aws", "terraform-*"]
    multi-ecosystem-group: "infrastructure"

有关可用选项的完整列表,请参阅 Dependabot 选项参考

5.验证配置

提交更改后,可以验证配置:

  1. 导航到存储库的 “见解 ”选项卡。
  2. 选择 依赖关系图,然后选择 Dependabot
  3. 确认多生态系统组显示在列表中。

下次计划的更新运行时,你将收到一个拉取请求,其中包含组中所有生态系统的更新。

故障排除

如果未看到合并拉取请求,请确保:

  • 为每个 patterns 生态系统定义密钥(使用 multi-ecosystem-group时是必需的)。
  • 所有生态系统在 multi-ecosystem-group 字段中使用相同的组名称。

延伸阅读

  •         [AUTOTITLE](/code-security/dependabot/working-with-dependabot/dependabot-options-reference)