{"meta":{"title":"使用 Dependabot 保持操作的最新状态","intro":"你可以使用 Dependabot 将你使用的操作更新到最新版本。","product":"安全性和代码质量","breadcrumbs":[{"href":"/zh/code-security","title":"安全性和代码质量"},{"href":"/zh/code-security/how-tos","title":"How-tos"},{"href":"/zh/code-security/how-tos/secure-your-supply-chain","title":"保护供应链"},{"href":"/zh/code-security/how-tos/secure-your-supply-chain/secure-your-dependencies","title":"保护依赖项"},{"href":"/zh/code-security/how-tos/secure-your-supply-chain/secure-your-dependencies/auto-update-actions","title":"自动更新操作"}],"documentType":"article"},"body":"# 使用 Dependabot 保持操作的最新状态\n\n你可以使用 Dependabot 将你使用的操作更新到最新版本。\n\n为Dependabot version updates启用GitHub Actions后，Dependabot将帮助确保存储库中的\\_workflow\\.yml\\_文件内对操作的引用，以及工作流内部使用的可重用工作流，始终保持最新。 有关详细信息，请参阅“[Dependabot 版本更新](/zh/code-security/concepts/supply-chain-security/dependabot-version-updates)”。\n\n## 为操作启用 Dependabot version updates\n\n1. 如果已为其他生态系统或包管理器启用 Dependabot version updates ，只需打开现有 `dependabot.yml` 文件。 否则，在存储库的 `dependabot.yml` 目录中创建一个 `.github` 配置文件。 有关详细信息，请参阅“[配置 Dependabot 版本更新](/zh/code-security/how-tos/secure-your-supply-chain/secure-your-dependencies/configure-version-updates#enabling-dependabot-version-updates)”。\n\n2. 指定 `\"github-actions\"` 为要监视的 `package-ecosystem`。\n\n3. 设置 `directory` 为 `\"/\"`，检查 `.github/workflows` 中的工作流文件。\n\n4. 设置 `schedule.interval` 以指定检查新版本的频率。\n\n5. 将 dependabot.yml 配置文件签入存储库的 `.github` 目录中。 如果已编辑现有文件，请保存所做的更改。\n\n你还可以在分支上启用 Dependabot version updates。 有关详细信息，请参阅“[配置 Dependabot 版本更新](/zh/code-security/how-tos/secure-your-supply-chain/secure-your-dependencies/configure-version-updates#enabling-version-updates-on-forks)”。\n\n## 用于 `dependabot.yml` 的示例 GitHub Actions 文件\n\n下面的示例`dependabot.yml`文件用于为GitHub Actions配置版本更新。\n`directory` 必须设置为 `\"/\"` 以检查 `.github/workflows` 中的工作流文件。\n`schedule.interval` 设置为 `\"weekly\"`。 签入或更新此文件后，Dependabot 会检查你的操作是否有新版本。\nDependabot 将为它发现的任何过时的操作提出版本更新拉取请求。 初始版本更新后， Dependabot 将继续每周检查一次过时的操作版本。\n\n```yaml copy\n# Set update schedule for GitHub Actions\n\nversion: 2\nupdates:\n\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      # Check for updates to GitHub Actions every week\n      interval: \"weekly\"\n```\n\n## 为操作配置 Dependabot version updates\n\n启用 Dependabot version updates 操作时，必须指定值 `package-ecosystem`， `directory`以及 `schedule.interval`。 您可以设置更多可选属性来进一步自定义版本更新。 有关详细信息，请参阅“[Dependabot 选项参考](/zh/code-security/reference/supply-chain-security/dependabot-options-reference)”。\n\n## 延伸阅读\n\n* [撰写工作流程](/zh/actions/how-tos/write-workflows)"}