Dependabot ファイルにオプションを追加することで、ニーズに合わせて`dependabot.yml`構成をカスタマイズできます。 たとえば、 Dependabot が適切なパッケージ マニフェスト ファイルを使用し、保持する依存関係のみを更新することを確認できます。
この記事では、便利なカスタマイズ オプションをまとめています。
マニフェスト ファイルの複数の場所を定義する
複数の場所に格納されているマニフェスト ファイルのDependabot version updatesを有効にする場合は、directoriesの代わりにdirectoryを使用できます。 たとえば、この構成では、異なるディレクトリに格納されているマニフェスト ファイルに対して 2 つの異なる更新スケジュールを設定しています。
# Specify the locations of the manifest files to update for each package manager
# using both `directories` and `directory`
version: 2
updates:
- package-ecosystem: "bundler"
# Update manifest files stored in these directories weekly
directories:
- "/frontend"
- "/backend"
- "/admin"
schedule:
interval: "weekly"
- package-ecosystem: "bundler"
# Update manifest files stored in the root directory daily
directory: "/"
schedule:
interval: "daily"
# Specify the locations of the manifest files to update for each package manager
# using both `directories` and `directory`
version: 2
updates:
- package-ecosystem: "bundler"
# Update manifest files stored in these directories weekly
directories:
- "/frontend"
- "/backend"
- "/admin"
schedule:
interval: "weekly"
- package-ecosystem: "bundler"
# Update manifest files stored in the root directory daily
directory: "/"
schedule:
interval: "daily"
-
パターンを使ってディレクトリの範囲を指定するには
YAML # Specify the root directory and directories that start with "lib-", # using globbing, for locations of manifest files version: 2 updates: - package-ecosystem: "composer" directories: - "/" - "/lib-*" schedule: interval: "weekly"# Specify the root directory and directories that start with "lib-", # using globbing, for locations of manifest files version: 2 updates: - package-ecosystem: "composer" directories: - "/" - "/lib-*" schedule: interval: "weekly" -
現在のディレクトリと再帰的なサブディレクトリ内のマニフェストを指定するには
YAML # Specify all directories from the current layer and below recursively, # using globstar, for locations of manifest files version: 2 updates: - package-ecosystem: "composer" directories: - "**/*" schedule: interval: "weekly"# Specify all directories from the current layer and below recursively, # using globstar, for locations of manifest files version: 2 updates: - package-ecosystem: "composer" directories: - "**/*" schedule: interval: "weekly"
特定の依存関係を無視する
プロジェクト内の特定の依存関係からの変更を採用する準備ができていない場合は、バージョン更新プログラムとセキュリティ更新プログラムのプル要求を開いたときにそれらの依存関係を無視するように Dependabot を構成できます。 次のいずれかの方法で実行できます:
ignoreファイル内の依存関係にdependabot.ymlオプションを構成します。- バージョン更新プログラムとセキュリティ更新プログラムの
@dependabot ignorepull request でDependabotコメント コマンドを使用します。- コメント コマンドを使うと、特定の依存関係やバージョンの更新プログラムを無視できます。
- 詳しくは、「依存関係の更新に関するPull Requestを管理する」をご覧ください。
以下に、ignore を使って更新する依存関係をカスタマイズする方法の例をいくつか示します。
-
特定のバージョンより後の更新プログラムを無視するには
YAML ignore: - dependency-name: "lodash:*" # Ignore versions of Lodash that are equal to or greater than 1.0.0 versions: [ ">=1.0.0" ]ignore: - dependency-name: "lodash:*" # Ignore versions of Lodash that are equal to or greater than 1.0.0 versions: [ ">=1.0.0" ]YAML ignore: - dependency-name: "sphinx" versions: [ "[1.1,)" ]ignore: - dependency-name: "sphinx" versions: [ "[1.1,)" ] -
パッチ更新プログラムを無視するには
YAML ignore: - dependency-name: "@types/node" # Ignore patch updates for Node update-types: ["version-update:semver-patch"]ignore: - dependency-name: "@types/node" # Ignore patch updates for Node update-types: ["version-update:semver-patch"] -
特定のバージョンまたはバージョンの範囲を無視するには、「特定のバージョンまたはバージョンの範囲を無視する」を参照してください。
依存関係または無視条件の無視を解除する場合は、dependabot.yml ファイルから無視条件を削除するか、pull request を再度開きます。
グループ化された更新プログラムの pull request については、@dependabot unignore コメント コマンドも使用できます。
@dependabot unignore コメント コマンドを使用すると、Dependabot pull request にコメントを付けることで、次の操作を行うことができます。
- 特定の無視条件を無視解除する
- 特定の依存関係を無視解除する
- Dependabot pull request 内のすべての依存関係のすべての無視条件を無視解除する
詳しくは、「依存関係の更新に関するPull Requestを管理する」をご覧ください。
特定の依存関係の更新を許可する
`allow`を使用して、保持する依存関係についてDependabotに通知できます。 通常、`allow` は `ignore` と組み合わせて使います。
既定では、 Dependabot では、マニフェストで明示的に定義されている依存関係 (direct 依存関係) に対してのみバージョン更新プル要求が作成されます。 この構成では、allowを使用して、依存関係の種類Dependabot維持することをallに通知します。 つまり、direct 依存関係とその依存関係 (間接依存関係、サブ依存関係、または一時依存関係とも呼ばれます) の両方です。 さらに、パターンDependabotに一致する名前を持つすべての依存関係を無視するように構成によってorg.xwiki.*に指示されます。これは、それらを維持するためのプロセスが異なるためです。
ヒント
Dependabot は **、許可** されているすべての依存関係をチェックし、 **無視された** 依存関係をすべて除外します。 依存関係が **許可** ステートメントと **ignore** ステートメントと一致する場合、その依存関係は無視されます。
`update-types`ルールで`allow`を使用して、更新を特定のセマンティック バージョン管理レベルに制限することもできます。
version: 2
registries:
# Helps find updates for non Maven Central dependencies
maven-xwiki-public:
type: maven-repository
url: https://nexus.xwiki.org/nexus/content/groups/public/
username: ""
password: ""
# Required to resolve xwiki-common SNAPSHOT parent pom
maven-xwiki-snapshots:
type: maven-repository
url: https://maven.xwiki.org/snapshots
username: ""
password: ""
updates:
- package-ecosystem: "maven"
directory: "/"
registries:
- maven-xwiki-public
- maven-xwiki-snapshots
schedule:
interval: "weekly"
allow:
# Allow both direct and indirect updates for all packages.
- dependency-type: "all"
ignore:
# Ignore XWiki dependencies. We have a separate process for updating them
- dependency-name: "org.xwiki.*"
open-pull-requests-limit: 15
version: 2
registries:
# Helps find updates for non Maven Central dependencies
maven-xwiki-public:
type: maven-repository
url: https://nexus.xwiki.org/nexus/content/groups/public/
username: ""
password: ""
# Required to resolve xwiki-common SNAPSHOT parent pom
maven-xwiki-snapshots:
type: maven-repository
url: https://maven.xwiki.org/snapshots
username: ""
password: ""
updates:
- package-ecosystem: "maven"
directory: "/"
registries:
- maven-xwiki-public
- maven-xwiki-snapshots
schedule:
interval: "weekly"
allow:
# Allow both direct and indirect updates for all packages.
- dependency-type: "all"
ignore:
# Ignore XWiki dependencies. We have a separate process for updating them
- dependency-name: "org.xwiki.*"
open-pull-requests-limit: 15
更新プログラムの特定のセマンティック バージョン管理レベルを許可する
`update-types`と`allow`を使用して、特定のセマンティック バージョン管理 (SemVer) レベルに更新を制限できます。 これは、Dependabot でプル要求を作成する必要がある更新プログラムの種類を明示的に指定する場合に便利です。
メモ
`update-types` は _バージョン_ 更新プログラムにのみ影響し、 _セキュリティ_ 更新プログラムには影響しません。 セキュリティ更新プログラムは、 `update-types` 設定に関係なく常に作成されます。
詳細については、update-typesの「」を参照してください。
`update-types`で`allow`を使用する方法を示す例をいくつか次に示します。
-
特定の依存関係に対してマイナー更新とパッチ更新のみを許可するには、
update-typesとdependency-nameを組み合わせることができます。YAML version: 2 updates: - package-ecosystem: "maven" directory: "/" schedule: interval: "weekly" allow: - dependency-name: "io.micrometer:micrometer-core" update-types: - "version-update:semver-minor" - "version-update:semver-patch"version: 2 updates: - package-ecosystem: "maven" directory: "/" schedule: interval: "weekly" allow: - dependency-name: "io.micrometer:micrometer-core" update-types: - "version-update:semver-minor" - "version-update:semver-patch" -
運用環境と開発の依存関係に異なる更新ポリシーを適用するには、
update-typesとdependency-typeを組み合わせることができます。YAML version: 2 updates: - package-ecosystem: "composer" directory: "/" schedule: interval: "monthly" allow: - dependency-type: "production" update-types: - "version-update:semver-patch" - dependency-type: "development" update-types: - "version-update:semver-minor" - "version-update:semver-patchversion: 2 updates: - package-ecosystem: "composer" directory: "/" schedule: interval: "monthly" allow: - dependency-type: "production" update-types: - "version-update:semver-patch" - dependency-type: "development" update-types: - "version-update:semver-minor" - "version-update:semver-patchこの例では、運用環境の依存関係はパッチ更新プログラムのみを受け取りますが、開発の依存関係はマイナー更新プログラムとパッチ更新プログラムの両方を受け取ります。
特定のバージョンまたはバージョンの範囲を無視する
`versions` を `ignore` と組み合わせて使うと、特定のバージョンまたはバージョンの範囲を無視できます。
-
特定のバージョンを無視するには
YAML ignore: - dependency-name: "django*" # Ignore version 11 versions: [ "11" ]ignore: - dependency-name: "django*" # Ignore version 11 versions: [ "11" ] -
バージョンの範囲を無視するには
YAML ignore: - dependency-name: "@types/node" versions: ["15.x", "14.x", "13.x"] - dependency-name: "xdg-basedir" # 5.0.0 has breaking changes as they switch to named exports # and convert the module to ESM # We can't use it until we switch to ESM across the project versions: ["5.x"] - dependency-name: "limiter" # 2.0.0 has breaking changes # so we want to delay updating. versions: ["2.x"]ignore: - dependency-name: "@types/node" versions: ["15.x", "14.x", "13.x"] - dependency-name: "xdg-basedir" # 5.0.0 has breaking changes as they switch to named exports # and convert the module to ESM # We can't use it until we switch to ESM across the project versions: ["5.x"] - dependency-name: "limiter" # 2.0.0 has breaking changes # so we want to delay updating. versions: ["2.x"]
無視するセマンティック バージョニング レベルを指定する
`update-types`で`ignore`を使用して無視する 1 つ以上のセマンティック バージョン管理 (SemVer) レベルを指定できます。 または、`update-types`で`allow`を使用して、許可する更新レベルを明示的に指定することもできます。「[更新プログラムの特定のセマンティック バージョン管理レベルを許可する](#allowing-specific-semantic-versioning-levels-for-updates)」を参照してください。
詳細については、update-typesの「」を参照してください。
この例では、 Dependabot は Node のパッチ バージョンを無視します。
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "express"
# For Express, ignore all updates for version 4 and 5
versions: ["4.x", "5.x"]
# For Lodash, ignore all updates
- dependency-name: "lodash"
- dependency-name: "@types/node"
# For Node types, ignore any patch versions
update-types: ["version-update:semver-patch"]
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "express"
# For Express, ignore all updates for version 4 and 5
versions: ["4.x", "5.x"]
# For Lodash, ignore all updates
- dependency-name: "lodash"
- dependency-name: "@types/node"
# For Node types, ignore any patch versions
update-types: ["version-update:semver-patch"]
バージョン管理戦略を定義する
既定では、 Dependabot は、アプリとして識別する依存関係の最小バージョン要件を増やそうとし、ライブラリとして識別する依存関係の新しいバージョンと古いバージョンの両方を含むように、許可されるバージョン要件を拡大します。
この既定の戦略は変更できます。 詳細については、versioning-strategyの「」を参照してください。
この例では、 Dependabot は、アプリとライブラリの両方の新しいバージョンと一致するように最小バージョン要件を増やします。
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
# Increase the minimum version for all npm dependencies
versioning-strategy: increase
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
# Increase the minimum version for all npm dependencies
versioning-strategy: increase
この例では、 Dependabot は、元の制約で新しいバージョンが許可されていない場合 にのみ 、最小バージョン要件を増やします。
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 20
rebase-strategy: "disabled"
# Increase the version requirements for pip
# only when required
versioning-strategy: increase-if-necessary
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 20
rebase-strategy: "disabled"
# Increase the version requirements for pip
# only when required
versioning-strategy: increase-if-necessary
ベンダリングされた依存関係を更新する
更新時にベンダー固有の依存関係を Dependabot に指示できます。
Dependabot では、Go モジュールのベンダー化された依存関係が自動的に維持されます。また、ベンダーの依存関係も更新するように Bundler を構成できます。
この例では、 vendor は Bundler の true に設定されています。つまり、 Dependabot は、リポジトリの ベンダー/キャッシュ ディレクトリに格納されている Bundler の依存関係も保持します。
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
# Vendoring Bundler
vendor: true
schedule:
interval: weekly
day: saturday
open-pull-requests-limit: 10
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
# Vendoring Bundler
vendor: true
schedule:
interval: weekly
day: saturday
open-pull-requests-limit: 10