跳至主要内容

使用 Dependabot 保持你的 Actions 更新

你可以使用 Dependabot 将你使用的 Actions 保持更新到最新版本。

谁可以使用此功能?

具有 写入 访问权限的用户

当你为 GitHub Actions 启用 Dependabot 版本更新时,Dependabot 将帮助确保仓库的 workflow.yml 文件以及工作流中使用的可复用工作流中的 Action 引用保持为最新。更多信息,请参阅 关于 Dependabot 版本更新

为 Actions 启用 Dependabot 版本更新

  1. 如果你已为其他生态系统或包管理器启用 Dependabot 版本更新,只需打开已有的 dependabot.yml 文件。否则,请在仓库的 .github 目录下创建一个 dependabot.yml 配置文件。更多信息,请参阅 配置 Dependabot 版本更新
  2. 将 "github-actions" 指定为要监视的 package-ecosystem
  3. directory 设置为 "/",以检查 .github/workflows 中的工作流文件。
  4. 设置 schedule.interval,以指定检查新版本的频率。
  5. 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 的过时版本。

YAML
# 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-ecosystemdirectoryschedule.interval 指定值。还有许多可选属性可供设置,以进一步自定义版本更新。更多信息,请参阅 Dependabot 选项参考

延伸阅读

© . This site is unofficial and not affiliated with GitHub, Inc.