利用多生态系统更新,可以将 Dependabot 跨不同的包生态系统拉取请求合并到每个组的单个 PR 中。 请参阅“多生态系统更新”。
先决条件
- 具有多个包生态系统中的依赖项的存储库
- 现有
.github/dependabot.yml文件。 请参阅“配置 Dependabot 版本更新”。
1.在 .github/dependabot.yml 文件中定义多生态系统组
在顶层 multi-ecosystem-groups 部分中,首先定义一个有时间表的组:
version: 2
multi-ecosystem-groups:
infrastructure:
schedule:
interval: "weekly"
updates:
# Your existing package ecosystems will go here
version: 2
multi-ecosystem-groups:
infrastructure:
schedule:
interval: "weekly"
updates:
# Your existing package ecosystems will go here
2. 将生态系统分配给组
将 multi-ecosystem-groups 密钥和模式添加到包生态系统配置。
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"
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.使用其他键进行自定义(可选)
可以将标签、审阅者或其他配置选项添加到多生态系统组。 请参阅 assignees 和 labels。
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"
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.验证配置
提交更改后,可以验证配置:
- 导航到存储库的 “见解 ”选项卡。
- 选择 依赖关系图,然后选择 Dependabot。
- 确认多生态系统组显示在列表中。
下次计划的更新运行时,你将收到一个拉取请求,其中包含组中所有生态系统的更新。
故障排除
如果未看到合并拉取请求,请确保:
- 为每个
patterns生态系统定义密钥(使用multi-ecosystem-group时是必需的)。 - 所有生态系统在
multi-ecosystem-group字段中使用相同的组名称。
延伸阅读
-
[AUTOTITLE](/code-security/dependabot/working-with-dependabot/dependabot-options-reference)