当你为 GitHub Actions 启用 Dependabot 版本更新时,Dependabot 将帮助确保仓库的 workflow.yml 文件以及工作流中使用的可复用工作流中的 Action 引用保持为最新。更多信息,请参阅 关于 Dependabot 版本更新。
为 Actions 启用 Dependabot 版本更新
- 如果你已为其他生态系统或包管理器启用 Dependabot 版本更新,只需打开已有的
dependabot.yml文件。否则,请在仓库的.github目录下创建一个dependabot.yml配置文件。更多信息,请参阅 配置 Dependabot 版本更新。 - 将 "github-actions" 指定为要监视的
package-ecosystem。 - 将
directory设置为 "/",以检查.github/workflows中的工作流文件。 - 设置
schedule.interval,以指定检查新版本的频率。 - 将
dependabot.yml配置文件提交至仓库的.github目录。如果你编辑了已有文件,请保存更改。
你也可以在分支仓库上启用 Dependabot 版本更新。更多信息,请参阅 配置 Dependabot 版本更新。
GitHub Actions 的 dependabot.yml 示例文件
下面的示例 dependabot.yml 文件配置了针对 GitHub Actions 的版本更新。必须将 directory 设置为 "/",以检查 .github/workflows 中的工作流文件。schedule.interval 被设为 "weekly"。在此文件提交或更新后,Dependabot 将检查你的 Actions 是否有新版本。Dependabot 会为发现的任何过时 Action 提交拉取请求进行版本更新。在首次版本更新后,Dependabot 将每周继续检查 Action 的过时版本。
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
配置 Actions 的 Dependabot 版本更新
在为 Actions 启用 Dependabot 版本更新时,必须为 package-ecosystem、directory 和 schedule.interval 指定值。还有许多可选属性可供设置,以进一步自定义版本更新。更多信息,请参阅 Dependabot 选项参考。