
GitHub Copilot 项目实战dependabot.yml 全量配置选项参考与依赖自动化实践【免费下载链接】awesome-copilotCommunity-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot.项目地址: https://gitcode.com/GitHub_Trending/aw/awesome-copilot.github/dependabot.yml是 GitHub Dependabot 的唯一配置入口掌控着仓库依赖的安全告警、安全更新与版本更新三大能力。本文以 awesome-copilot 仓库中 dependabot 技能集 的官方 YAML 参考文档为主体完整梳理从文件骨架、必需键、分组、过滤、PR 定制到私有仓库配置的全部选项并结合仓库内 github-actions 供应链安全指南 与 vcpkg CI 指南 等配套资源帮助你在任何规模的仓库含 monorepo中写出可落地、可维护、低噪音的依赖自动化配置。配置文件的整体骨架所有 Dependabot 配置都集中存放在默认分支上的单个文件.github/dependabot.yml中GitHub 不支持一个仓库存在多个dependabot.yml多生态、多目录场景应通过一个文件内的多个updates条目来表达。完整的顶层结构如下摘自 dependabot-yml-reference.mdversion: 2 # 必需恒为 2 registries: # 可选私有仓库访问配置 REGISTRY_NAME: type: ... url: ... multi-ecosystem-groups: # 可选跨生态分组 GROUP_NAME: schedule: interval: ... updates: # 必需生态配置列表 - package-ecosystem: ... # 必需 directory: / # 必需或 directories schedule: # 必需 interval: ...其中version必须位于顶层且恒为2updates是配置的核心列表每一个条目对应一个被监控的包管理生态。必需键详解package-ecosystem选择被监控的包管理器一个updates条目对应一个生态同一生态可以写多个条目以覆盖不同目录。Dependabot 依据清单文件manifest识别依赖完整生态取值与对应清单文件如下包管理器YAML 值清单文件BazelbazelMODULE.bazel、WORKSPACEBunbunbun.lockbBundler (Ruby)bundlerGemfile、Gemfile.lockCargo (Rust)cargoCargo.toml、Cargo.lockComposer (PHP)composercomposer.json、composer.lockCondacondaenvironment.ymlDev Containersdevcontainersdevcontainer.jsonDockerdockerDockerfileDocker Composedocker-composedocker-compose.yml.NET SDKdotnet-sdkglobal.jsonElmelmelm.jsonGit Submodulesgitsubmodule.gitmodulesGitHub Actionsgithub-actions.github/workflows/*.ymlGo Modulesgomodgo.mod、go.sumGradlegradlebuild.gradle、build.gradle.ktsHelmhelmChart.yamlHex (Elixir)mixmix.exs、mix.lockJuliajuliaProject.toml、Manifest.tomlMavenmavenpom.xmlnpm/pnpm/yarnnpmpackage.json及各类 lockfileNuGetnuget*.csproj、packages.configOpenTofuopentofu*.tfpip/pipenv/poetry/uvpiprequirements.txt、Pipfile、pyproject.tomlPre-commitpre-commit.pre-commit-config.yamlPub (Dart/Flutter)pubpubspec.yamlRust Toolchainrust-toolchainrust-toolchain.tomlSwiftswiftPackage.swiftTerraformterraform*.tfuvuvuv.lock、pyproject.tomlvcpkgvcpkgvcpkg.json使用要点来自 SKILL.md 的生态检测清单pnpm 与 yarn 都使用npm生态值Dependabot 会自动识别pnpm-lock.yaml、yarn.lock若仓库同时存在uv.lock优先使用uv生态值否则退回pip仓库内 vcpkg CI 指南 演示了vcpkg生态的最小配置可用于保持 vcpkg 端口基线builtin-baseline的自动更新。directory/directories定位清单文件directory指定相对于仓库根目录的单一路径不支持 globdirectories是复数形式可列出多个路径并支持*与**glob# 单一目录 directory: / # 多目录 glob directories: - / - /apps/* - /packages/*对于 GitHub Actions 生态directory固定写/Dependabot 会自动搜索.github/workflows/目录下的 workflow 文件。schedule更新频率schedule决定 Dependabot 多久检查一次新版本参数取值说明intervaldaily、weekly、monthly、quarterly、semiannually、yearly、cron必需daymonday–sunday仅weekly生效timeHH:MM默认 UTCtimezoneIANA 时区字符串如America/New_YorkcronjobCron 表达式当interval为cron时必需schedule: interval: weekly day: tuesday time: 09:00 timezone: Europe/London使用cron可精确控制执行时刻例如cronjob: 0 9 * * 1表示每周一 9:00 运行示例见 example-configs.md。分组选项把海量 PR 合并成少数可审阅的 PRgroups生态内分组groups将同一生态内的多个依赖更新合并到同一个 PR显著降低 PR 噪音与 CI 成本。参数用途取值IDENTIFIER组名出现在分支/PR 标题字母、竖线、下划线、连字符applies-to更新类型version-updates默认、security-updatesdependency-type按类型过滤development、productionpatterns按名称包含匹配字符串列表支持*通配exclude-patterns按名称排除匹配字符串列表支持*通配update-typesSemVer 过滤major、minor、patchgroup-by跨目录分组dependency-namegroups: dev-deps: dependency-type: development update-types: [minor, patch] angular: patterns: [angular*] exclude-patterns: [angular/cdk] monorepo: group-by: dependency-name关键行为摘自 SKILL.md同时匹配多个组的依赖进入最先匹配的组applies-to缺省时仅作用于version-updates未分组的依赖仍会收到独立 PR。跨目录分组group-by: dependency-name让同一依赖在多个目录中同时更新时只产生一个 PR如 lodash 在三个子应用同时升级只开一个 PR。注意其限制所有目录必须属于同一包管理生态、仅适用于版本更新、版本约束互不兼容时会拆分为多个 PR。multi-ecosystem-groups跨生态分组multi-ecosystem-groups是顶层键把不同生态的依赖更新合并进同一个 PR适合基础设施类依赖multi-ecosystem-groups: GROUP_NAME: schedule: interval: weekly labels: [infrastructure] assignees: [platform-team]在updates条目中通过multi-ecosystem-group: GROUP_NAME归属组。注意使用该特性时每个生态条目中patterns键是必需的参考 example-configs.md 的 Docker Terraform 示例。过滤选项精确控制更新什么、不更新什么allow显式白名单只维护列出的依赖参数用途dependency-name按名称匹配支持*通配dependency-typedirect、indirect、all、production、developmentallow: - dependency-type: production - dependency-name: expressignore排除依赖或版本参数用途dependency-name按名称匹配支持*通配versions指定版本或范围如[5.x]、[2.0.0]update-typesSemVer 级别version-update:semver-major、version-update:semver-minor、version-update:semver-patchignore: - dependency-name: lodash - dependency-name: types/node update-types: [version-update:semver-patch] - dependency-name: express versions: [5.x]优先级规则如果依赖同时命中allow与ignore最终被ignore忽略。exclude-paths跳过扫描目录忽略特定目录或文件使其不参与清单扫描exclude-paths: - vendor/** - test/fixtures/** - *.lock支持三种 glob 形态*单段、**递归、具体文件路径。PR 定制选项labels与assigneeslabels: - dependencies - npm assignees: - user1 - user2labels: []可禁用全部标签仓库中若已存在 SemVer 标签major/minor/patch无论配置如何都会自动附加。assignees 必须对仓库拥有写权限组织仓库可为读权限。milestone、commit-message、pull-request-branch-namemilestone: 4 # 里程碑 URL 中的数字 ID commit-message: prefix: deps # 最多 50 字符以字母/数字结尾时自动追加冒号 prefix-development: deps-dev # 开发依赖的独立前缀 include: scope # 在前缀后追加 deps/deps-dev 作用域 pull-request-branch-name: separator: - # 可选值-、_、/target-branchtarget-branch: develop设置后版本更新 PR 将基于该分支而非默认分支。安全更新永远以默认分支为目标且target-branch只会作用于版本更新配置。调度与限流cooldown新版本冷却期延迟处理刚发布的新版本避免早鸟踩坑参数用途default-days默认冷却天数1–90 天semver-major-days大版本更新冷却semver-minor-days小版本更新冷却semver-patch-days补丁更新冷却include应用冷却的依赖最多 150 个支持*exclude豁免冷却的依赖最多 150 个优先级更高cooldown: default-days: 5 semver-major-days: 30 semver-minor-days: 7 semver-patch-days: 3 include: [*] exclude: [critical-security-lib]注意cooldown仅作用于版本更新不作用于安全更新SKILL.md 明确说明。open-pull-requests-limitopen-pull-requests-limit: 10 # 版本更新默认 5设置为0将完全禁用版本更新 PR安全更新仍会进行其内部独立上限为 10。这是只做安全更新场景的核心开关。高级选项versioning-strategy版本约束的编辑策略受支持生态bundler、cargo、composer、mix、npm、pip、pub、uv。值行为auto默认应用项目提升最小值库项目放宽范围increase总是提升最小版本increase-if-necessary仅当当前范围不包含新版本时才修改lockfile-only只更新 lockfile不动清单widen放宽范围同时兼容新旧版本rebase-strategy与vendorrebase-strategy: disabled # 默认在冲突时自动 rebasePR 打开 30 天后停止 vendor: true # 维护 vendored 依赖受支持生态bundler、gomod在提交信息中包含[dependabot skip]可允许 Dependabot 在额外提交之上强制推送 rebase。Go modules 会自动探测 vendored 依赖。insecure-external-code-execution受支持生态bundler、mix、pip。允许 Dependabot 在更新期间执行清单中的代码——部分生态在依赖解析阶段需要运行代码此时必须开启insecure-external-code-execution: allow私有仓库Private Registries配置顶层registries定义支持 npm、Maven、Docker、Python 等私有源registries: npm-private: type: npm-registry url: https://npm.example.com token: ${{secrets.NPM_TOKEN}} maven-central: type: maven-repository url: https://repo.maven.apache.org/maven2 username: password: docker-ghcr: type: docker-registry url: https://ghcr.io username: ${{secrets.GHCR_USER}} password: ${{secrets.GHCR_TOKEN}} python-private: type: python-index url: https://pypi.example.com/simple token: ${{secrets.PYPI_TOKEN}}在生态条目中关联updates: - package-ecosystem: npm directory: / registries: - npm-private schedule: interval: weekly使用registries: *可允许该条目访问全部已定义仓库。完整的私有 npm Docker 组合示例见 example-configs.md。仓库内的 Dependabot 实践佐证awesome-copilot 仓库自身将 Dependabot 作为供应链安全的一环来使用可作为实际落地参考github-actions 供应链安全指南 强调第三方 GitHub Actions 应以不可变的 40 位 commit SHA固定版本可变 tag 可能被上游恶意重指向并让 Dependabot 维护这些 SHA 固定——Dependabot 能识别# vX.Y.Z注释并自动提升 SHA配置方式即标准的github-actions生态条目version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: weeklyvcpkg CI 指南 给出了 C 生态的 Dependabot 用法vcpkg.json的builtin-baseline自动更新与手动脚本方案互为替代。实战速查几类高频完整配置最小单生态配置example-configs.mdversion: 2 updates: - package-ecosystem: npm directory: / schedule: interval: weekly仅安全更新禁用版本更新version: 2 updates: - package-ecosystem: npm directory: / schedule: interval: daily open-pull-requests-limit: 0 # 禁用版本更新 PR groups: security-all: applies-to: security-updates patterns: [*] update-types: [patch, minor]monorepo 分组 冷却 私有源全功能配置完整 5 生态示例npm 工作区、GitHub Actions、Docker、pip、Terraform见 example-configs.md 的 Full-Featured Configuration 一节其中演示了directoriesglob、group-by: dependency-name、cooldown、versioning-strategy与按生态差异化commit-message前缀如ci、infra的组合用法。PR 注释命令与维护技巧对单个 PR 或分组 PR 可以评论dependabot command进行交互Dependabot 会以 表情确认命令作用dependabot rebase基于目标分支 rebase PRdependabot recreate从头重建 PR覆盖手工修改dependabot ignore this dependency关闭 PR 并永久停止该依赖更新dependabot ignore this major version等按 major/minor/patch 维度忽略dependabot show DEPENDENCY_NAME ignore conditions查看当前忽略条件表分组 PR 额外支持dependabot ignore DEPENDENCY_NAME、dependabot unignore DEPENDENCY_NAME、dependabot unignore *等命令完整命令表见 pr-commands.md。两点重要提醒源自 pr-commands.md 的弃用公告自 2026 年 1 月起dependabot merge、squash and merge、cancel merge、close、reopen命令已被移除请改用 GitHub 原生 UI、gh pr mergeCLI 或 auto-merge通过 PR 注释产生的 ignore 是集中存储的对团队仓库透明性而言优先把规则写进dependabot.yml的ignore键。FAQ能否有多个dependabot.yml不能。GitHub 每个仓库只支持.github/dependabot.yml一个文件多生态/多目录用多个updates条目表达。Dependabot 支持 pnpm 吗支持。使用package-ecosystem: npmDependabot 自动识别pnpm-lock.yaml。如何降低 monorepo 的 PR 噪音组合使用groups批量更新、directories glob 全覆盖、group-by: dependency-name跨目录合并对低优先级生态可选用monthly/quarterly间隔。如何处理工作区之外的独立包为它单独写一个生态条目directory指向其所在目录即可。如何通过 AI 编码 Agent 在提交前扫描依赖漏洞安装 GitHub MCP Server 的 Advanced Security 插件advanced-securitycopilot-plugins启用dependabot工具集copilot --add-github-mcp-toolset dependabot即可在提交前针对新增依赖查询 GitHub Advisory Database返回受影响包、严重级别与建议修复版本详见 SKILL.md 的 Pre-Commit Dependency Scanning 一节。【免费下载链接】awesome-copilotCommunity-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot.项目地址: https://gitcode.com/GitHub_Trending/aw/awesome-copilot创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考