独自の内部プロセスに適するように、 Dependabot pull request をカスタマイズするさまざまな方法があります。
たとえば、 Dependabotのプル要求を CI/CD パイプラインに統合するために、 カスタム ラベル をプル要求に適用し、アクション ワークフローをトリガーするために使用できます。
複数のカスタマイズ オプションがあり、すべてを組み合わせて使って、パッケージ エコシステムごとに調整できます。
担当者の自動追加
既定では、 Dependabot は、割り当てユーザーなしでプル要求を発生させます。
指定したセキュリティ チームに pull request を自動的に割り当てるには、assignees を使ってパッケージ エコシステムごとにこれらの値を設定できます。
次の dependabot.yml ファイル例では、npm のバージョンおよびセキュリティ更新プログラムを使って開かれたすべての pull request が次のようになるように npm の構成を変更しています。
- Pull request に自動的に割り当てられる個人 ("
user-name")。
# `dependabot.yml` file with
# assignee for all npm pull requests
version: 2
updates:
# Keep npm dependencies up to date
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Raise all npm pull requests with assignees
assignees:
- "user-name"
# `dependabot.yml` file with
# assignee for all npm pull requests
version: 2
updates:
# Keep npm dependencies up to date
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Raise all npm pull requests with assignees
assignees:
- "user-name"
レビュー担当者の自動追加
既定では、 Dependabot はレビュー担当者なしでプル要求を発生させます。
プロジェクトのセキュリティ更新プログラムが適切なチームによって迅速に対処されるように、CODEOWNERS ファイルを使用してレビュー担当者を Dependabot pull request に自動的に追加できます。 「コードオーナーについて」を参照してください。
カスタム ラベルを使って pull request にラベルを付ける
既定では、 Dependabot は、 dependencies ラベルを持つプル要求を発生させます。
Dependabot また、 java、 npm、 github-actionsなどのエコシステム ラベルをプル要求に適用します。
Dependabot では、フィルター処理とトリアージを向上させるために、単一エコシステムの更新を含むすべてのプル要求に、 dependencies ラベルとエコシステム ラベルの両方が追加されます。
Dependabot は、リポジトリにまだ存在しない場合にプル要求に適用される既定のラベルを作成します。 既定値ではなくカスタム ラベルを使用する場合は、パッケージ エコシステムごとに labels ファイルで dependabot.yml オプションを設定できます。これにより、既定値がオーバーライドされます。 詳細については、「ラベルを管理する」と labels を参照してください。
セマンティック バージョン (SemVer) ラベルがリポジトリに存在する場合、 Dependabot は、バージョン更新の種類 (major、 minor、または patch) を示すためにも自動的に適用されます。 これらのラベルは、定義したカスタム ラベルに加えて適用されます。
labels を使うと、既定のラベルをオーバーライドし、パッケージ エコシステムごとに独自のカスタム ラベルを指定できます。 これは、たとえば次のような場合に便利です。
- ラベルを使って、特定の pull request に優先順位を割り当てます。
- ラベルを使って、pull request をプロジェクト ボードに自動的に追加するなど、別のワークフローをトリガーします。
次の dependabot.yml ファイル例では、npm のバージョンおよびセキュリティ更新プログラムで開かれたすべての pull request にカスタム ラベルが割り当てられるように npm 構成を変更しています。
# `dependabot.yml` file with
# customized npm configuration
version: 2
updates:
# Keep npm dependencies up to date
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Raise all npm pull requests with custom labels
labels:
- "npm dependencies"
- "triage-board"
# `dependabot.yml` file with
# customized npm configuration
version: 2
updates:
# Keep npm dependencies up to date
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Raise all npm pull requests with custom labels
labels:
- "npm dependencies"
- "triage-board"
target-branch を使って既定以外のブランチのバージョン アップデートをチェックしないかぎり、このオプションの設定も、このパッケージ マネージャーのマニフェスト ファイルに対するセキュリティ更新プログラムの pull request に影響します。
参照 labels.
コミット メッセージにプレフィックスを追加する
既定では、 Dependabot はコミット メッセージの基本設定を検出し、同様のパターンを使用しようとします。 さらに、 Dependabot はコミット メッセージに基づいてプル要求のタイトルを設定します。
特定のパッケージ エコシステムの Dependabotのコミット メッセージ (および pull request タイトル) には、独自のプレフィックスを指定できます。 これは、たとえば、コミット メッセージや pull request のタイトルを処理する自動化を実行している場合に便利です。
設定を明示的に指定するには、commit-message を次のサポートされているオプションと共に使います。
prefix:- すべてのコミット メッセージのプレフィックスを指定します。
- Pull request のタイトルの先頭にもプレフィックスが追加されます。
prefix-development:- パッケージ マネージャーまたはエコシステムによって定義されているように、開発の依存関係を更新するすべてのコミット メッセージに個別のプレフィックスを指定します。
bundler、composer、mix、maven、npm、pipに対してサポートされています。
include: "scope":- 任意のプレフィックスの後に、コミットで更新された依存関係の種類 (
depsまたはdeps-dev) が続くことを指定します。
- 任意のプレフィックスの後に、コミットで更新された依存関係の種類 (
次の例は、パッケージ エコシステムごとに調整された複数のオプションを示しています。
# Customize commit messages
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
commit-message:
# Prefix all commit messages with "npm: "
prefix: "npm"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
commit-message:
# Prefix all commit messages with "[docker] " (no colon, but a trailing whitespace)
prefix: "[docker] "
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
# Prefix all commit messages with "Composer" plus its scope, that is, a
# list of updated dependencies
commit-message:
prefix: "Composer"
include: "scope"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Include a list of updated dependencies
# with a prefix determined by the dependency group
commit-message:
prefix: "pip prod"
prefix-development: "pip dev"
# Customize commit messages
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
commit-message:
# Prefix all commit messages with "npm: "
prefix: "npm"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
commit-message:
# Prefix all commit messages with "[docker] " (no colon, but a trailing whitespace)
prefix: "[docker] "
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
# Prefix all commit messages with "Composer" plus its scope, that is, a
# list of updated dependencies
commit-message:
prefix: "Composer"
include: "scope"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Include a list of updated dependencies
# with a prefix determined by the dependency group
commit-message:
prefix: "pip prod"
prefix-development: "pip dev"
target-branch を使って既定以外のブランチのバージョン アップデートをチェックしないかぎり、このオプションの設定も、このパッケージ マネージャーのマニフェスト ファイルに対するセキュリティ更新プログラムの pull request に影響します。
参照 commit-message.
Pull request とマイルストーンを関連付ける
マイルストーンは、プロジェクトの目標またはリリースに向けた pull request (または issue) のグループの進行状況を追跡するのに役立ちます。
Dependabotでは、milestone オプションを使用して、依存関係の更新に対するプル要求を特定のマイルストーンに関連付けることができます。
マイルストーンのラベルではなく、その数値識別子を指定する必要があります。 数値識別子を見つけるには、ページ URL の最後の部分 (milestone の後) をチェックします。 たとえば、https://github.com/<org>/<repo>/milestone/3、"3" はマイルストーンの数値識別子です。
# Specify a milestone for pull requests
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Associate pull requests with milestone "4"
milestone: 4
# Specify a milestone for pull requests
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Associate pull requests with milestone "4"
milestone: 4
target-branch を使って既定以外のブランチのバージョン アップデートをチェックしないかぎり、このオプションの設定も、このパッケージ マネージャーのマニフェスト ファイルに対するセキュリティ更新プログラムの pull request に影響します。
「milestone」と「マイルストーンについて」も参照してください。
Pull request ブランチ名の区切り記号を変更する
Dependabot は、プルリクエストごとにブランチを生成します。 各ブランチ名には、dependabot に加えて、パッケージ マネージャーの名前と更新対象の依存関係が含まれます。 既定では、ブランチ名のこれらの部分は、/ 記号で区切られています。次に例を示します。
dependabot/npm_and_yarn/next_js/acorn-6.4.1
既存のプロセスとのサポート性または整合性を保持するには、必要に応じて、ブランチ名がチームの既存の規約と一致していることを確認します。 この場合、pull-request-branch-name.separator を使って別の区切り記号を指定し、_、/、または "-" のいずれかを選択できます。
次の例では、npm の構成により、既定の区切り記号が / から "-" に変更され、次のようになります。
- 既定値 (
/):dependabot/npm_and_yarn/next_js/acorn-6.4.1 - カスタマイズ後 (
"-"):dependabot-npm_and_yarn-next_js-acorn-6.4.1
ハイフン記号 ("-") は、空の YAML リストの開始として解釈されないように、引用符で囲む必要があることに注意してください。
# Specify a different separator for branch names
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
pull-request-branch-name:
# Change the default separator (/) to a hyphen (-)
separator: "-"
# Specify a different separator for branch names
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
pull-request-branch-name:
# Change the default separator (/) to a hyphen (-)
separator: "-"
target-branch を使って既定以外のブランチのバージョン アップデートをチェックしないかぎり、このオプションの設定も、このパッケージ マネージャーのマニフェスト ファイルに対するセキュリティ更新プログラムの pull request に影響します。
参照 pull-request-branch-name.separator.
既定ではないブランチに対する pull request をターゲットに設定する
既定では、 Dependabot は既定のブランチでマニフェスト ファイルをチェックし、既定のブランチに対して更新のプル要求を発生させます。
一般に、 Dependabotのチェックと更新を既定のブランチに保持するのが最も理にかなっています。 ただし、場合によっては、別のターゲット ブランチを指定する必要があります。 たとえば、チームのプロセスで、最初に非運用ブランチで更新プログラムをテストして検証する必要がある場合は、 target-branch を使用して、プル要求を発生させる Dependabot に別のブランチを指定できます。
メモ
Dependabot は、既定のブランチに対してのみ、セキュリティ更新プログラムのプル リクエストを作成します。 target-branch を使うと、結果として、そのパッケージ マネージャーのすべての構成設定は、セキュリティ更新プログラムではなくバージョン更新プログラムに "のみ" 適用されます。__
# Specify a non-default branch for pull requests for pip
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Raise pull requests for version updates
# to pip against the `develop` branch
target-branch: "develop"
# Labels on pull requests for version updates only
labels:
- "pip dependencies"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Check for npm updates on Sundays
day: "sunday"
# Labels on pull requests for security and version updates
labels:
- "npm dependencies"
# Specify a non-default branch for pull requests for pip
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Raise pull requests for version updates
# to pip against the `develop` branch
target-branch: "develop"
# Labels on pull requests for version updates only
labels:
- "pip dependencies"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# Check for npm updates on Sundays
day: "sunday"
# Labels on pull requests for security and version updates
labels:
- "npm dependencies"
参照 target-branch.