关于 dependabot.yml 文件
Dependabot 配置文件 dependabot.yml 使用 YAML 语法。 如果你不熟悉 YAML 并且想要了解详细信息,请参阅“在五分钟内了解 YAML”。
必须将此文件存储在存储库的 .github 目录中。 在添加或更新 dependabot.yml 文件时,这将立即触发版本更新检查。 有关详细信息和示例,请参阅“配置 Dependabot 版本更新”。
下次安全警报触发安全更新的拉取请求时将使用所有同时影响安全更新的选项。 有关详细信息,请参阅“配置 Dependabot security updates”。
注意:不能使用 dependabot.yml 文件配置 Dependabot alerts。
dependabot.yml 文件有两个必需的顶级项:version 和 updates。 可以选择包括顶级 registries 项。 该文件必须以 version: 2 开头。
dependabot.yml 文件的配置选项
顶级 updates 项是必需的。 您使用它来配置 Dependabot 如何更新版本或项目的依赖项。 每个条目都为特定的包管理器配置更新设置。 您可以使用以下选项。
| 选项 | 必需 | 安全更新 | 版本更新 | 说明 |
|---|---|---|---|---|
package-ecosystem | X | X | 要使用的包管理器 | |
directory | X | X | 包清单位置 | |
schedule.interval | X | X | 检查更新的频率 | |
allow | X | X | 自定义允许的更新 | |
assignees | X | X | 要在拉取请求上设置的受让人 | |
commit-message | X | X | 提交消息首选项 | |
enable-beta-ecosystems | X | 启用具有 beta 级支持的生态系统 | ||
ignore | X | X | 忽略某些依赖项或版本 | |
insecure-external-code-execution | X | 允许或拒绝清单文件中的代码执行 | ||
labels | X | X | 要在拉取请求上设置的标签 | |
milestone | X | X | 要在拉取请求上设置的里程碑 | |
open-pull-requests-limit | X | X | 限制对版本更新打开的拉取请求数 | |
pull-request-branch-name.separator | X | X | 更改拉取请求分支名称的分隔符 | |
rebase-strategy | X | X | 禁用自动变基 | |
registries | X | Dependabot 可以访问的私有注册表 | ||
reviewers | X | X | 要在拉取请求上设置的审查者 | |
schedule.day | X | 检查更新的周日期 | ||
schedule.time | X | 每天检查更新的时间 (hh:mm) | ||
schedule.timezone | X | 一天中时间的时区(区域标识符) | ||
target-branch | X | 对其创建拉取请求的分支 | ||
vendor | X | 更新供应或缓存的依赖项 | ||
versioning-strategy | X | X | 如何更新清单版本要求 |
这些选项大致分为以下类别。
- 必须在所有配置中包含的基本设置选项:
package-ecosystem、directory、schedule.interval。 - 用于自定义更新计划的选项:
schedule.time、schedule.timezone、schedule.day。 - 用于控制要更新的依赖项的选项:
allow、ignore、vendor。 - 用于向拉取请求添加元数据的选项:
reviewers、assignees、labels、milestone。 - 用于更改拉取请求的行为的选项:
target-branch、versioning-strategy、commit-message、rebase-strategy、pull-request-branch-name.separator。
此外,open-pull-requests-limit 选项会更改 Dependabot 可以打开的版本更新的最大拉取请求数。
注意:其中一些配置选项还可能会影响针对易受攻击的程序包清单安全更新提出的拉取请求。
仅对默认分支上有漏洞的包清单提出安全更新。 如果为同一分支设置了配置选项(除非使用 target-branch,否则为 true),并为易受攻击的清单指定了 package-ecosystem 和 directory,则安全更新的拉取请求将使用相关选项。
一般而言,安全更新会使用影响拉取请求的任何配置选项,例如添加元数据或改变其行为。 有关安全更新的详细信息,请参阅“配置 Dependabot security updates”。
package-ecosystem
“必需”。 你为希望 Dependabot 监视新版本的每个包管理器添加一个 package-ecosystem 元素。 仓库还必须包含其中每个包管理器的依赖项清单或锁定文件。 如果您想要为支持它的软件包管理器启用供应,则必须在所需的目录中找到供应的依赖项。 有关详细信息,请参阅下面的 vendor。
下表对每个包管理器显示:
- 要在 dependabot.yml 文件中使用的 YAML 值
- 支持的包管理器版本
- 是否支持私有 GitHub 仓库或注册表中的依赖项
- 是否支持供应的依赖项
| 程序包管理器 | YAML 值 | 支持的版本 | 私有仓库 | 专用注册表 | 供应 |
|---|---|---|---|---|---|
| Bundler | bundler | v1, v2 | ✓ | ✓ | |
| Cargo | cargo | v1 | ✓ | ✓ | |
| 编辑器 | composer | v1, v2 | ✓ | ✓ | |
| Docker [1] | docker | v1 | ✓ | ✓ | |
| Hex | mix | v1 | ✓ | ||
| elm-package | elm | v0.19 | ✓ | ✓ | |
| git submodule | gitsubmodule | N/A(无版本) | ✓ | ✓ | |
| GitHub Actions [2] | github-actions | N/A(无版本) | ✓ | ✓ | |
| Go 模块 | gomod | v1 | ✓ | ✓ | ✓ |
| Gradle [3] | gradle | N/A(无版本) | ✓ | ✓ | |
| Maven [4] | maven | N/A(无版本) | ✓ | ✓ | |
| npm | npm | v6、v7、v8 | ✓ | ✓ | |
| NuGet | nuget | <= 4.8[5] | ✓ | ✓ | |
| pip[6] | pip | v21.1.2 | ✓ | ||
| pipenv | pip | <= 2021-05-29 | ✓ | ||
| pip-compile[6] | pip | 6.1.0 | ✓ | ||
| poetry | pip | v1 | ✓ | ||
| pub [7] | pub | v2 | |||
| Terraform | terraform | >= 0.13、<= 1.3.x | ✓ | ✓ | |
| yarn | npm | V1、V2、V3 | ✓ | ✓ | ✓[8] |
提示:对于包管理器(如 pipenv 和 poetry),需要使用 pip YAML 值。 例如,如果使用 poetry 来管理 Python 依赖项,并且希望让 Dependabot 监视新版本的依赖项清单文件,请在 dependabot.yml 文件中使用 package-ecosystem: "pip"。
[1] Dependabot 可更新 Kubernetes 清单中的 Docker 映像标记。 对于包含引用 Docker 映像标记的 Kubernetes 清单的每个目录,请向 dependabot.yml 文件的 Docker package-ecosystem 元素添加一个条目。 Kubernetes 清单可以是 Kubernetes 部署 YAML 文件或 Helm 图表。 有关为 docker 配置 dependabot.yml 文件的信息,请参阅“dependabot.yml 文件的配置选项”中的“package-ecosystem”。
Dependabot 支持公共和专用 Docker 注册表。 有关支持的注册表的列表,请参阅“dependabot.yml 文件的配置选项”中的“docker-registry”。
[2] Dependabot 仅支持使用 GitHub 存储库语法(例如 actions/checkout@v3)更新 GitHub Actions。 目前不支持 Docker Hub 和 GitHub Packages Container registry URL。
[3] Dependabot 不运行 Gradle,但支持对以下文件的更新:build.gradle、build.gradle.kts(针对 Kotlin 项目),以及通过 apply 声明包含在内且文件名中带有 dependencies 的文件。 请注意,apply 不支持 apply to、递归或高级语法(例如,Kotlin 的 apply 和 mapOf,由属性定义的文件名)。
[4] Dependabot 不运行 Maven,但支持对 pom.xml 文件的更新。
[5] Dependabot 不运行 NuGet CLI,但支持版本 4.8 及更早版本中的大多数功能。
[6] 除支持更新 requirements.txt 文件外,Dependabot 还支持更新 pyproject.toml 文件(如果它们遵循 PEP 621 标准)。
[7] Dependabot 在尝试更新到的版本被忽略时不会为 pub 执行更新,即使有可用的早期版本也是如此。
[8] Dependabot 支持 v2 及更高版本的 vendored 依赖项。
# Basic set up for three package managers
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# Maintain dependencies for npm
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Maintain dependencies for Composer
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
directory
“必需”。 必须为每个包管理器定义程序包清单的位置(例如 package.json 或 Gemfile) 。 为所有生态系统(GitHub Actions 除外)定义相对于仓库根目录的目录。 对于 GitHub Actions,请将目录设置为 /,以检查 .github/workflows 中的工作流文件。
# Specify location of manifest files for each package manager
version: 2
updates:
- package-ecosystem: "composer"
# Files stored in repository root
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm"
# Files stored in `app` directory
directory: "/app"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
schedule.interval
“必需”。 必须为每个包管理器定义检查新版本的频率。 默认情况下, Dependabot 随机分配一个时间来应用配置文件中的所有更新。 若要设置特定时间,可以使用 schedule.time 和 schedule.timezone。
| 时间间隔类型 | 频率 |
|---|---|
daily | 在每个工作日(周一至周五)运行。 |
weekly | 每周运行一次。 默认情况下为星期一。 若要对此进行修改,请使用 schedule.day。 |
monthly | 每月运行一次。 在每月的第一天运行。 |
# Set update schedule for each package manager
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
- package-ecosystem: "composer"
directory: "/"
schedule:
# Check for updates managed by Composer once a week
interval: "weekly"
注意:schedule 定义 Dependabot 尝试新更新的时间。 但是,这不是您可收到拉取请求的唯一时间。 可以基于对 dependabot.yml 文件所做的更改、在更新失败后对清单文件的更改或 Dependabot security updates 触发更新。 有关详细信息,请参阅“Dependabot 拉取请求的频率”和“关于 Dependabot security updates”。
allow
默认情况下,清单中明确定义的所有依赖项都通过 Dependabot 版本更新保持最新。 此外,Dependabot 安全更新还更新了锁定文件中定义的易受攻击的依赖项。 可以使用 allow 和 ignore 自定义要维护的依赖项。 Dependabot 可检查所有被允许的依赖项,然后过滤到任何被忽略的依赖项或版本。 因此,将忽略由 allow 和 ignore 匹配的依赖项。
使用 allow 选项自定义更新的依赖项。 这适用于版本和安全更新。 您可以使用下列选项:
-
dependency-name- 用于允许具有匹配名称的依赖项的更新,可以选择使用*匹配零个或多个字符。 对于 Java 依赖项,dependency-name属性的格式为groupId:artifactId,例如:org.kohsuke:github-api。 -
dependency-type- 用于允许特定类型的依赖项的更新。依赖项类型 支持的包管理器 允许更新 directAll 所有明确定义的依赖项。 indirectbundler、pip、composer、cargo、gomod直接依赖关系的依赖项(也称为子依赖项或暂时依赖项)。 allAll 所有明确定义的依赖项。 bundler、pip、composer、cargo、gomod,以及直接依赖关系的依赖项。productionbundler,composer,mix,maven,npm,pip仅“产品依赖项组”中的依赖项。 developmentbundler,composer,mix,maven,npm,pip仅“产品依赖项组”中的依赖项。
# Use `allow` to specify which dependencies to maintain
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
allow:
# Allow updates for Lodash
- dependency-name: "lodash"
# Allow updates for React and any packages starting "react"
- dependency-name: "react*"
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
allow:
# Allow both direct and indirect updates for all packages
- dependency-type: "all"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
allow:
# Allow only direct updates for
# Django and any packages starting "django"
- dependency-name: "django*"
dependency-type: "direct"
# Allow only production updates for Sphinx
- dependency-name: "sphinx"
dependency-type: "production"
assignees
使用 assignees 为针对包管理器提出的所有拉取请求指定单个代理人。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Specify assignees for pull requests
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Add assignees
assignees:
- "octocat"
commit-message
默认情况下,Dependabot 会尝试检测您的提交消息首选项并使用类似的模式。 使用 commit-message 选项可显式指定首选项。
支持的选项
注意:prefix 和 prefix-development 选项限 50 个字符。
prefix指定所有提交消息的前缀。prefix-development为更新开发依赖项组中的依赖项的所有提交消息指定单独的前缀。 为该选项指定值时,prefix仅用于更新生产依赖项组中的依赖项。 这由bundler、composer、mix、maven、npm和pip支持。include: "scope"指定任何前缀都后跟提交中更新的依赖项列表。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Customize commit messages
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
commit-message:
# Prefix all commit messages with "npm"
prefix: "npm"
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
# Prefix all commit messages with "Composer"
# include a list of updated dependencies
commit-message:
prefix: "Composer"
include: "scope"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Include a list of updated dependencies
# with a prefix determined by the dependency group
commit-message:
prefix: "pip prod"
prefix-development: "pip dev"
include: "scope"
如果使用与上述示例相同的配置,则升级 pip 开发依赖项组中的 requests 库将生成提交消息:
pip dev: bump requests from 1.0.0 to 1.0.1
ignore
默认情况下,清单中明确定义的所有依赖项都通过 Dependabot 版本更新保持最新。 此外,Dependabot 安全更新还更新了锁定文件中定义的易受攻击的依赖项。 可以使用 allow 和 ignore 自定义要维护的依赖项。 Dependabot 可检查所有被允许的依赖项,然后过滤到任何被忽略的依赖项或版本。 因此,将忽略由 allow 和 ignore 匹配的依赖项。
通过将依赖项添加到 ignore,或者对由 Dependabot 打开的拉取请求使用 @dependabot ignore 命令,可以忽略依赖项。
从 @dependabot ignore 创建 ignore 条件
使用 @dependabot ignore 命令忽略的依赖项将针对每个包管理器集中存储。 如果开始忽略 dependabot.yml 文件中的依赖项,则这些现有首选项将与配置中的 ignore 依赖项一起考虑。
可以通过在存储库中搜索 "@dependabot ignore" in:comments 来检查该存储库是否存储了 ignore 首选项。 如果您希望取消忽略以这种方式忽略的依赖项,请重新打开拉取请求。
有关 @dependabot ignore 命令的详细信息,请参阅“管理依赖项更新的拉取请求”。
指定要忽略的依赖项和版本
可以使用 ignore 选项自定义更新的依赖项。 ignore 选项支持以下选项。
dependency-name- 用于忽略具有匹配名称的依赖项的更新,可以选择使用*匹配零个或多个字符。 对于 Java 依赖项,dependency-name属性的格式为groupId:artifactId(例如:org.kohsuke:github-api)。 要防止 Dependabot 从 DefinitelyTyped 自动更新 TypeScript 类型定义,请使用@types/*。versions- 用于忽略特定版本或版本范围。 如果要定义范围,请使用包管理器的标准模式(例如:对于 npm,请使用^1.0.0;对于 Bundler,请使用~> 2.0)。update-types- 用于忽略更新类型,例如版本更新的 semvermajor、minor或patch更新(例如:version-update:semver-patch将忽略修补程序更新)。 可以将其与dependency-name: "*"相结合,以忽略所有依赖项的特定update-types。 目前,仅支持version-update:semver-major、version-update:semver-minor和version-update:semver-patch选项。 安全更新不受此设置的影响。
如果结合使用 versions 和 update-types,Dependabot 将忽略任一集中的任何更新。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Use `ignore` to specify dependencies that should not be updated
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "express"
# For Express, ignore all updates for version 4 and 5
versions: ["4.x", "5.x"]
# For Lodash, ignore all updates
- dependency-name: "lodash"
# For AWS SDK, ignore all patch updates
- dependency-name: "aws-sdk"
update-types: ["version-update:semver-patch"]
注意:Dependabot 在可以访问文件中的所有依赖项时,只能在清单或锁定文件上运行版本更新,即使你将不可访问的依赖项添加到配置文件的 ignore 选项也是如此。 有关详细信息,请参阅“管理组织的安全和分析设置”和“排查 Dependabot 错误”。
注意:对于 pub 生态系统,Dependabot 在其尝试更新到的版本被忽略时不会执行更新,即使有可用早期版本也是如此。
insecure-external-code-execution
包含 package-ecosystem 值 bundler、mix 和 pip 的包管理器可能会在版本更新过程中在清单中执行外部代码。 这可能允许受损害的软件包窃取凭据或访问已配置的注册。 在 updates 配置中添加 registries 设置时,Dependabot 会自动阻止外部代码执行,在此情况下,版本更新可能会失败。 可以选择通过将 insecure-external-code-execution 设置为 allow 来替代此行为,允许针对 bundler、mix 和 pip 包管理器的外部代码执行。
可以通过将 insecure-external-code-execution 设置为 deny 显式拒绝外部代码执行,而不考虑此更新配置是否有 registries 设置。
# Allow external code execution when updating dependencies from private registries
version: 2
registries:
ruby-github:
type: rubygems-server
url: https://rubygems.pkg.github.com/octocat/github_api
token: ${{secrets.MY_GITHUB_PERSONAL_TOKEN}}
updates:
- package-ecosystem: "bundler"
directory: "/rubygems-server"
insecure-external-code-execution: allow
registries: "*"
schedule:
interval: "monthly"
labels
默认情况下,Dependabot 会提出所有带有 dependencies 标签的拉取请求。 如果定义了多个包管理器,Dependabot 在每个拉取请求上都会包含一个附加标签。 这表示拉取请求将更新的语言或生态系统,例如:java 表示 Gradle 更新,submodules 表示 git 子模块。 Dependabot 将根据需要自动在您的仓库中创建这些默认标签。
使用 labels 替代默认标签,并为针对包管理器提出的所有拉取请求指定替代标签。 如果其中任何标签未在仓库中定义,将被忽略。
若要禁用所有标签(包括默认标签),请使用 labels: [ ]。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Specify labels for pull requests
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Specify labels for npm pull requests
labels:
- "npm"
- "dependencies"
milestone
使用 milestone 将针对包管理器提出的所有拉取请求与里程碑相关联。 您需要指定里程碑的数字标识符,而不是其标签。 如果查看里程碑,则 milestone 之后的页面 URL 的最后一部分是标识符。 例如:https://github.com/<org>/<repo>/milestone/3。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Specify a milestone for pull requests
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Associate pull requests with milestone "4"
milestone: 4
open-pull-requests-limit
默认情况下, Dependabot 最多打开五个版本更新的拉取请求。 Dependabot 中有五个打开的拉取请求后,Dependabot 不会打开任何新请求,直到其中一些打开的请求合并或关闭。 使用 open-pull-requests-limit 可以更改此限制。 这也提供了一个简单的方法来暂时禁用包管理器的版本更新。
此选项对安全更新没有影响,因为安全更新具有单独的内部限制:10 个打开的拉取请求。
# Specify the number of open pull requests allowed
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Disable version updates for npm dependencies
open-pull-requests-limit: 0
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Allow up to 10 open pull requests for pip dependencies
open-pull-requests-limit: 10
pull-request-branch-name.separator
Dependabot 为每个拉取请求生成分支。 每个分支名称都包括 dependabot,以及更新的包管理器和依赖项。 默认情况下,这些部分由 / 符号分隔,例如:dependabot/npm_and_yarn/next_js/acorn-6.4.1。
使用 pull-request-branch-name.separator 指定不同的分隔符。 这可以是 "-"、_ 或 / 之一。 连字符必须用引号括住,否则会解释为开始一个空的 YAML 列表。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Specify a different separator for branch names
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
pull-request-branch-name:
# Separate sections of the branch name with a hyphen
# for example, `dependabot-npm_and_yarn-next_js-acorn-6.4.1`
separator: "-"
rebase-strategy
默认情况下,Dependabot 会在检测到拉取请求有任何更改时自动变基打开的拉取请求。 使用 rebase-strategy 可以禁用此行为。
可用的变基策略
auto用于在检测到更改时使用默认行为并变基打开的拉取请求。disabled用于禁用自动变基。
当 rebase-strategy 设置为 auto 时,Dependabot 会基于以下情况下尝试变基拉取请求。
- 使用 Dependabot version updates 时,适用于计划运行时任何打开的 Dependabot 拉取请求。
- 重新打开已关闭的 Dependabot 拉取请求。
- 在 Dependabot 配置文件中更改
target-branch的值时。 有关此字段的详细信息,请参阅“target-branch”。 - 当 Dependabot 检测到 Dependabot 拉取请求在最近推送到目标分支后发生冲突时。
注意:Dependabot 将无限期地变基拉取请求,直到拉取请求关闭、合并或你禁用 Dependabot updates。
当 rebase-strategy 设置为 disabled 时,Dependabot 将停止变基拉取请求。
注意:此行为仅适用于与目标分支冲突的拉取请求。 Dependabot 将继续变基在更改 rebase-strategy 设置之前打开的拉取请求,以及计划运行中的拉取请求。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Disable automatic rebasing
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Disable rebasing for npm pull requests
rebase-strategy: "disabled"
registries
若要在执行版本更新时允许 Dependabot 访问专用包注册表,必须在相关 updates 配置中包含 registries 设置。 可以通过将 registries 设置为 "*" 来允许使用所有已定义的注册表。 或者,您可以列出更新可以使用的注册表。 为此,请使用 dependabot.yml 文件的顶级 registries 部分中定义的注册表名称。 有关详细信息,请参阅下面的“专用注册表的配置选项”。
若要允许 Dependabot 使用 bundler、mix 和 pip 包管理器更新专用注册表中的依赖项,可以选择允许外部代码执行。 有关详细信息,请参阅上面的 insecure-external-code-execution。
# Allow Dependabot to use one of the two defined private registries
# when updating dependency versions for this ecosystem
version: 2
registries:
maven-github:
type: maven-repository
url: https://maven.pkg.github.com/octocat
username: octocat
password: ${{secrets.MY_ARTIFACTORY_PASSWORD}}
npm-npmjs:
type: npm-registry
url: https://registry.npmjs.org
username: octocat
password: ${{secrets.MY_NPM_PASSWORD}}
updates:
- package-ecosystem: "gitsubmodule"
directory: "/"
registries:
- maven-github
schedule:
interval: "monthly"
reviewers
使用 reviewers 为针对包管理器提出的所有拉取请求指定单个审阅者或审阅者团队。 必须使用完整的团队名称,包括组织,就像你是 @mentioning 团队一样。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
# Specify reviewers for pull requests
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Add reviewers
reviewers:
- "octocat"
- "my-username"
- "my-org/python-team"
schedule.day
设置 weekly 更新计划时,默认情况下,Dependabot 会在周一的随机设置时间检查存储库的新版本。 使用 schedule.day 可以指定检查更新的备用日期。
支持的值
mondaytuesdaywednesdaythursdayfridaysaturdaysunday
# Specify the day for weekly checks
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Check for npm updates on Sundays
day: "sunday"
schedule.time
默认情况下,Dependabot 在仓库的随机设置时间检查新版本。 使用 schedule.time 可以指定检查更新的备用时间(格式:hh:mm)。
# Set a time for checks
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Check for npm updates at 9am UTC
time: "09:00"
schedule.timezone
默认情况下,Dependabot 在仓库的随机设置时间检查新版本。 使用 schedule.timezone 可以指定备用时区。 时区标识符必须来自 iana 维护的时区数据库。 有关详细信息,请参阅 tz 数据库时区列表。
# Specify the timezone for checks
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
time: "09:00"
# Use Japan Standard Time (UTC +09:00)
timezone: "Asia/Tokyo"
target-branch
默认情况下,Dependabot 会检查默认分支上的清单文件,并对此分支提出版本更新的拉取请求。 使用 target-branch 可以为清单文件和拉取请求指定不同的分支。 使用此选项时,此包管理器的设置将不再影响针对安全更新提出的任何拉取请求。
# Specify a non-default branch for pull requests for pip
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Raise pull requests for version updates
# to pip against the `develop` branch
target-branch: "develop"
# Labels on pull requests for version updates only
labels:
- "pip dependencies"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Check for npm updates on Sundays
day: "sunday"
# Labels on pull requests for security and version updates
labels:
- "npm dependencies"
vendor
使用 vendor 选项指示 Dependabot 在更新依赖项时提供其供应商。 如果使用 gomod,请勿使用此选项,因为 Dependabot 会自动检测此工具的供应。
# Configure version updates for both dependencies defined in manifests and vendored dependencies
version: 2
updates:
- package-ecosystem: "bundler"
# Raise pull requests to update vendored dependencies that are checked in to the repository
vendor: true
directory: "/"
schedule:
interval: "weekly"
Dependabot 仅更新位于仓库的特定目录中供应的依赖项。
| 程序包管理器 | 供应的依赖项所需的文件路径 | 详细信息 |
|---|---|---|
bundler | 依赖项必须位于 vendor/cache 目录中。 不支持其他文件路径。 | bundle cache 文档 |
gomod | 无路径要求(依赖项通常位于 vendor 目录中) | go mod vendor 文档 |
versioning-strategy
Dependabot 在编辑清单文件来更新版本时,使用以下总体策略:
- 对于 app,版本要求会增加,例如:npm、pip 和 Composer。
- 对于库,版本的范围会扩大,例如: Bundler 和 Cargo。
使用 versioning-strategy 选项可以更改受支持的包管理器的此行为。
设置此选项还会影响此包管理器的清单文件安全更新拉取请求,除非使用 target-branch 检查非默认分支上的版本更新。
可用的更新策略
| 选项 | 支持的服务 | 操作 |
|---|---|---|
lockfile-only | bundler, cargo, composer, mix, npm, pip | 仅创建用于更新 lockfiles 的拉取请求。 忽略任何需要包清单更改的新版本。 |
auto | bundler, cargo, composer, mix, npm, pip | 遵循上述默认策略。 |
widen | composer, npm | 尽可能放宽版本要求,以包括新旧版本。 |
increase | bundler、composer、npm、pip | 始终增加版本要求以匹配新版本。 |
increase-if-necessary | bundler、composer、npm、pip | 仅当新版本需要时才增加版本要求。 |
# Customize the manifest version strategy
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Update the npm manifest file to relax
# the version requirements
versioning-strategy: widen
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
# Increase the version requirements for Composer
# only when required
versioning-strategy: increase-if-necessary
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Only allow updates to the lockfile for pip and
# ignore any version updates that affect the manifest
versioning-strategy: lockfile-only
私人注册的配置选项
顶级 registries 项是可选的。 它允许您指定 Dependabot 可用于访问私人包注册表的身份验证详细信息。
注意:不支持专用网络上防火墙后面的专用注册表。
registries 项的值是一个关联阵列,其中每个元素由一个标识特定注册表的键和一个为关联阵列的值组成,该值指定访问该注册表所需的设置。 以下 dependabot.yml 文件在文件的 registries 部分配置一个标识为 dockerhub 的注册表,然后在文件的 updates 部分中引用该注册表。
# Minimal settings to update dependencies in one private registry
version: 2
registries:
dockerhub: # Define access for a private registry
type: docker-registry
url: registry.hub.docker.com
username: octocat
password: ${{secrets.DOCKERHUB_PASSWORD}}
updates:
- package-ecosystem: "docker"
directory: "/docker-registry/dockerhub"
registries:
- dockerhub # Allow version updates for dependencies in this registry
schedule:
interval: "monthly"
您使用以下选项来指定访问设置。 注册表设置必须包含 type 和 url,并且通常包含 username 和 password 组合或 token。
| 选项 | 说明 |
|---|---|
type | 识别注册表的类型。 请参阅下面的完整类型列表。 |
url | 用于访问此注册表中的依赖项的 URL。 协议是可选的。 如果未指定,则假定为 https://。 Dependabot 根据需要添加或忽略尾随斜线。 |
username | Dependabot 用于访问注册表的用户名。 |
password | 引用包含指定用户密码的 Dependabot 机密。 有关详细信息,请参阅“管理 Dependabot 的加密机密”。 |
key | 引用包含此注册表访问密钥的 Dependabot 机密。 有关详细信息,请参阅“管理 Dependabot 的加密机密”。 |
token | 引用包含此注册表访问令牌的 Dependabot 机密。 有关详细信息,请参阅“管理 Dependabot 的加密机密”。 |
replaces-base | 对于注册表,如果布尔值为 true,Dependabot 会使用指定的 URL 而不是特定生态系统的基 URL 来解析依赖项。 例如,对于包含 type: python-index 的注册表,如果布尔值为 true,pip 会使用指定的 URL 而不是 Python 包索引的基 URL(默认为 https://pypi.org/simple)来解析依赖项。 |
每个配置 type 都要求提供特定设置。 某些类型允许多种连接方式。 以下部分提供了每个 type 应该使用的设置的详细信息。
composer-repository
composer-repository 类型支持用户名和密码。
registries:
composer:
type: composer-repository
url: https://repo.packagist.com/example-company/
username: octocat
password: ${{secrets.MY_PACKAGIST_PASSWORD}}
docker-registry
Dependabot 可与实现 OCI 容器注册表规范的任何容器注册表配合使用。有关详细信息,请参阅 https://github.com/opencontainers/distribution-spec/blob/main/spec.md。 Dependabot 支持通过中央令牌服务或 HTTP 基本身份验证对专用注册表进行身份验证。有关更多详细信息,请参阅 Docker 文档中的令牌身份验证规范和维基百科上的基本访问身份验证。
docker-registry 类型支持用户名和密码。
registries:
dockerhub:
type: docker-registry
url: https://registry.hub.docker.com
username: octocat
password: ${{secrets.MY_DOCKERHUB_PASSWORD}}
replaces-base: true
docker-registry 类型还可用于通过静态 AWS 凭据从专用 Amazon ECR 中拉取。
registries:
ecr-docker:
type: docker-registry
url: https://1234567890.dkr.ecr.us-east-1.amazonaws.com
username: ${{secrets.ECR_AWS_ACCESS_KEY_ID}}
password: ${{secrets.ECR_AWS_SECRET_ACCESS_KEY}}
replaces-base: true
git
git 类型支持用户名和密码。
registries:
github-octocat:
type: git
url: https://github.com
username: x-access-token
password: ${{secrets.MY_GITHUB_PERSONAL_TOKEN}}
hex-organization
hex-organization 类型支持组织和密钥。
registries:
github-hex-org:
type: hex-organization
organization: github
key: ${{secrets.MY_HEX_ORGANIZATION_KEY}}
hex-repository
hex-repository 类型支持身份验证密钥。
repo 是必填字段,必须与依赖项声明中使用的存储库的名称匹配。
public-key-fingerprint 为可选配置字段,表示 Hex 存储库的公钥指纹。 Hex 使用 public-key-fingerprint 与专用存储库建立信任关系。 public-key-fingerprint 字段可以以纯文本形式列出,也可以存储为 Dependabot 机密。
registries:
github-hex-repository:
type: hex-repository
repo: private-repo
url: https://private-repo.example.com
auth-key: ${{secrets.MY_AUTH_KEY}}
public-key-fingerprint: ${{secrets.MY_PUBLIC_KEY_FINGERPRINT}}
maven-repository
maven-repository 类型支持用户名和密码。
registries:
maven-artifactory:
type: maven-repository
url: https://artifactory.example.com
username: octocat
password: ${{secrets.MY_ARTIFACTORY_PASSWORD}}
replaces-base: true
npm-registry
npm-registry 类型支持用户名和密码或者令牌。
使用用户名和密码时,.npmrc 的身份验证令牌可能包含 base64 编码的 _password;但是,Dependabot 配置文件中引用的密码必须是原始(未编码)密码。
registries:
npm-npmjs:
type: npm-registry
url: https://registry.npmjs.org
username: octocat
password: ${{secrets.MY_NPM_PASSWORD}} # Must be an unencoded password
replaces-base: true
registries:
npm-github:
type: npm-registry
url: https://npm.pkg.github.com
token: ${{secrets.MY_GITHUB_PERSONAL_TOKEN}}
replaces-base: true
出于安全原因,Dependabot 不会设置环境变量。 Yarn(v2 及更高版本)要求设置任何访问的环境变量。 访问 .yarnrc.yml 文件中的环境变量时,应提供回退值,例如 ${ENV_VAR-fallback} 或 ${ENV_VAR:-fallback}。 有关详细信息,请参阅 Yarn 文档中的 Yarnrc 文件。
nuget-feed
nuget-feed 类型支持用户名和密码或者令牌。
registries:
nuget-example:
type: nuget-feed
url: https://nuget.example.com/v3/index.json
username: octocat@example.com
password: ${{secrets.MY_NUGET_PASSWORD}}
registries:
nuget-azure-devops:
type: nuget-feed
url: https://pkgs.dev.azure.com/.../_packaging/My_Feed/nuget/v3/index.json
username: octocat@example.com
password: ${{secrets.MY_AZURE_DEVOPS_TOKEN}}
python-index
python-index 类型支持用户名和密码或者令牌。
registries:
python-example:
type: python-index
url: https://example.com/_packaging/my-feed/pypi/example
username: octocat
password: ${{secrets.MY_BASIC_AUTH_PASSWORD}}
replaces-base: true
registries:
python-azure:
type: python-index
url: https://pkgs.dev.azure.com/octocat/_packaging/my-feed/pypi/example
username: octocat@example.com
password: ${{secrets.MY_AZURE_DEVOPS_TOKEN}}
replaces-base: true
rubygems-server
rubygems-server 类型支持用户名和密码或者令牌。
registries:
ruby-example:
type: rubygems-server
url: https://rubygems.example.com
username: octocat@example.com
password: ${{secrets.MY_RUBYGEMS_PASSWORD}}
replaces-base: true
registries:
ruby-github:
type: rubygems-server
url: https://rubygems.pkg.github.com/octocat/github_api
token: ${{secrets.MY_GITHUB_PERSONAL_TOKEN}}
replaces-base: true
terraform-registry
terraform-registry 类型支持令牌。
registries:
terraform-example:
type: terraform-registry
url: https://terraform.example.com
token: ${{secrets.MY_TERRAFORM_API_TOKEN}}
启用对 beta 级生态系统的支持
enable-beta-ecosystems
默认情况下,Dependabot 仅针对完全支持的生态系统更新依赖项清单和锁定文件。 使用 enable-beta-ecosystems 标志选择加入尚未正式发布的生态系统更新。
# Configure beta ecosystem
version: 2
enable-beta-ecosystems: true
updates:
- package-ecosystem: "beta-ecosystem"
directory: "/"
schedule:
interval: "weekly"