Skip to main content

使用 Dependabot 保持操作的最新状态

您可以使用 Dependabot 来确保您使用的操作更新到最新版本。

谁可以使用此功能?

Users with write access

当你为 GitHub Actions 启用 Dependabot version updates 后,Dependabot 将帮助确保存储库的 workflow.yml 文件中对操作的引用,以及工作流中使用的可重用工作流,始终保持最新。 有关详细信息,请参阅“关于 Dependabot 版本更新”。

为操作启用 Dependabot version updates

  1. 如果你已经为其他生态系统或包管理器启用 Dependabot version updates,只需打开现有的 dependabot.yml 文件。 否则,在存储库的 dependabot.yml 目录中创建一个 .github 配置文件。 有关详细信息,请参阅“配置 Dependabot 版本更新”。
  2. 指定 "github-actions" 为要监视的 package-ecosystem
  3. 设置 directory"/",检查 .github/workflows 中的工作流文件。
  4. 设置 schedule.interval 以指定检查新版本的频率。
  5. 将 dependabot.yml 配置文件签入存储库的 .github 目录中。 如果已编辑现有文件,请保存所做的更改。

您也可以在复刻上启用 Dependabot version updates。 有关详细信息,请参阅“配置 Dependabot 版本更新”。

例如用于 GitHub Actions

dependabot.yml 文件

下面的示例 dependabot.yml 文件配置 GitHub Actions 的版本更新。 directory 必须设置为 "/" 以检查 .github/workflows 中的工作流文件。 schedule.interval 设置为 "weekly"。 在该文件被检入或更新后,Dependabot 将检查您的操作的新版本。 Dependabot 在发现任何过时的操作时,将会提出版本更新的拉取请求。 在初始版本更新后,Dependabot 将继续每周检查一次过时的操作版本。

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"

为操作配置 Dependabot version updates

为操作启用 Dependabot version updates 时,必须指定 package-ecosystemdirectoryschedule.interval 的值。 您可以设置更多可选属性来进一步自定义版本更新。 有关详细信息,请参阅“Dependabot 选项参考”。

延伸阅读

  •         [AUTOTITLE](/actions/learn-github-actions)