Skip to main content

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

你可以使用 Dependabot 将你使用的操作更新到最新版本。

谁可以使用此功能?

Users with write access

注意

站点管理员必须先为 Dependabot updates设置 你的 GitHub Enterprise Server 实例,然后你才能使用此功能。 有关详细信息,请参阅 为企业启用 Dependabot.

如果企业所有者在企业级别设置了策略,你可能无法启用或禁用 Dependabot updates。 有关详细信息,请参阅“强制实施企业的代码安全性和分析策略”。

为Dependabot version updates启用GitHub Actions后,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-ecosystemdirectory以及 schedule.interval。 您可以设置更多可选属性来进一步自定义版本更新。 有关详细信息,请参阅“Dependabot 选项参考”。

延伸阅读