Skip to main content

Enterprise Server 3.19 は、現在リリース候補として使用できます。

Dependabot 用にマルチエコシステム更新を構成する

複数のエコシステム間で更新プログラムをグループ化するように Dependabot を構成して、エコシステムごとに 1 つの pull request を受け取るのではなく、グループごとに 1 つの統合された pull request を受け取る方法について説明します。

この機能を使用できるユーザーについて

Users with write access

マルチエコシステム更新について

マルチエコシステム更新を使うと、複数のパッケージ エコシステムにまたがるグループを作成し、サポートされているすべてのエコシステムの更新を含む 1 つの Dependabot pull request を得られます。 このアプローチにより、受け取る Dependabot pull request 数を削減し、依存関係の更新ワークフローを効率化できます。

マルチエコシステム更新は、特に次のような場合に役立ちます。

  • 複数のテクノロジ (Docker、Terraform、Python スクリプト) を使うインフラストラクチャ プロジェクト
  • フロントエンドとバックエンドの依存関係があり、一緒に更新する必要があるフル スタック アプリケーション
  • 複数の言語間でプロトコルのバージョンを同期する必要があるクロスプラットフォーム ライブラリ

はじめに

最初のマルチエコシステム グループを設定するには、次の手順に従ってください。

1.multi-ecosystem-groups ファイルに .github/dependabot.yml を追加する

まず、最上位の multi-ecosystem-groups セクションで、スケジュールを含むグループを定義します。

YAML
version: 2

multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"

updates:
  # Your existing package ecosystems will go here

2.パターンを使ってグループにエコシステムを割り当てる

  1.        `multi-ecosystem-group` キーを追加します。
    
  2. パッケージ エコシステム構成に patterns を追加します。
YAML
version: 2

multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"

updates:
  - package-ecosystem: "docker"
    directory: "/"
    patterns: ["nginx", "redis", "postgres"]
    multi-ecosystem-group: "infrastructure"

  - package-ecosystem: "terraform"
    directory: "/"
    patterns: ["aws", "terraform-*"]
    multi-ecosystem-group: "infrastructure"

重要

          `patterns` を使う場合は `multi-ecosystem-group` キーが必要です。 依存関係パターンを指定してグループ内の特定の依存関係のみを含めるか、`["*"]` を使ってすべての依存関係を含めることができます。

3.統合された pull request をコミットして監視する

          `dependabot.yml` ファイルへの変更をコミットすると、Dependabot により、次のことが行われます。
  • グループのスケジュールに従って更新プログラムをチェックする
  • グループのスケジュールに従って更新をチェックする。
  • グループで指定されたすべてのエコシステムの更新を含む 1 つの pull request を作成する。
  • ブランチ名と pull request のタイトルにグループ識別子を使う。

4. 追加のキーを使用してカスタマイズする (省略可能)

          [
          `assignees`
          ](/code-security/dependabot/working-with-dependabot/dependabot-options-reference#assignees--)、[`labels`](/code-security/dependabot/working-with-dependabot/dependabot-options-reference#labels--)、その他の設定をグループに追加します。
YAML
multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"
    assignees: ["@platform-team"]
    labels: ["infrastructure", "dependencies"]

updates:
  - package-ecosystem: "docker"
    directory: "/"
    patterns: ["nginx", "redis", "postgres"]
    multi-ecosystem-group: "infrastructure"

  - package-ecosystem: "terraform"
    directory: "/"
    patterns: ["aws", "terraform-*"]
    multi-ecosystem-group: "infrastructure"

マルチエコシステム固有の構成

マルチエコシステム更新では、2 レベルの構成構造を使って、更新のグループ化と管理の方法を柔軟に制御できます。

  •         **グループレベル** (`multi-ecosystem-groups`): グループ内のすべてのパッケージ エコシステムに適用されるグループ全体の動作、スケジュール、共有設定を定義します。
    
  •         **エコシステムレベル** (`updates`): 含める依存関係やエコシステム固有の設定など、グループ内の個々のパッケージ マネージャーを構成します。
    

この構造により、個々のパッケージ エコシステムに対するきめ細かな制御を維持しながら、グループ レベルで一貫性のあるポリシーを設定できます。

multi-ecosystem-groups

複数のパッケージ エコシステムにまたがるグループを定義します。 各グループには次の要件があります。

  •         **グループ識別子**: ブランチ名と pull request のタイトルで使用されます。
    
  •         **スケジュール**: 更新をチェックする頻度。 使用できるすべてのオプションについては、「[schedule](/code-security/dependabot/working-with-dependabot/dependabot-options-reference#schedule-)」を参照してください。
    

multi-ecosystem-group

パッケージ エコシステムをマルチ エコシステム グループに割り当てます。 含める依存関係を指定するには、patterns キーが必要です。

          `patterns` の詳細については、[`patterns` と `exclude-patterns`](/code-security/dependabot/working-with-dependabot/dependabot-options-reference#patterns-and-exclude-patterns-groups) を参照してください。

その他の構成オプション

すべての標準の Dependabot 構成オプションは、マルチエコシステム グループで使用できます。 「package-ecosystem」の directoryallowignore を参照してください。

キーの構成

マルチエコシステム グループを使う場合、キーは 2 つのレベルで構成されます。 どのキーをどこで使用できるかの完全な内訳は次のとおりです。

グループ レベル (multi-ecosystem-groups)

次の表は、グループ レベルで使用できる構成キーとその動作の種類を示しています。 詳細については、「構成の動作」を参照してください。

Key必須Behavior
schedule適用なし
labels加法
milestoneグループのみ
assignees加法
target-branchグループのみ
commit-messageグループのみ
pull-request-branch-nameグループのみ

エコシステムレベル (updates)

次の表は、エコシステム レベルで使用できる構成キーとその動作の種類を示しています。 詳細については、「構成の動作」を参照してください。

Key必須Behavior
package-ecosystem適用なし
directory / directories適用なし
patterns適用なし
allow適用なし
ignore適用なし
registries適用なし
vendor適用なし
versioning-strategy適用なし
update-types適用なし
cooldown適用なし
labels加法
assignees加法

構成の動作

付加型キー

付加型キーは、グループ レベルと個々のエコシステム レベルの値を一方が他方を上書きするのではなく、両方の値をマージするものです。 これにより、グループ レベルでチーム全体に一貫性のある構成を設定しながら、個別のレベルで特定のエコシステムの専門知識を追加できます。

  •         `assignees` - グループ レベルとエコシステム レベルのすべての担当者が割り当てられます
    
  •         `labels` - グループ レベルとエコシステム レベルのすべてのラベルが適用されます
    

次の表は、次の例で Dependabot が Docker pull request のグループ レベルとエコシステム レベルの両方の値を結合する方法を示しています。

回答内容グループレベルの値エコシステムレベルの値結果
assignees
          `@platform-team`、`@security-lead`   | `@docker-admin`         | 
          `@platform-team`、`@security-lead`、`@docker-admin`           |

| labels | infrastructuredependencies | dockercontainers | infrastructuredependenciesdocker, containers |

YAML
multi-ecosystem-groups:
  infrastructure:
    assignees: ["@platform-team", "@security-lead"]
    labels: ["infrastructure", "dependencies"]

updates:
  - package-ecosystem: "docker"
    assignees: ["@docker-admin"]
    labels: ["docker", "containers"]
    multi-ecosystem-group: "infrastructure"

グループのみのキー

  •         `milestone` - 整数のマイルストーン番号
    
  •         `commit-message` - コミット メッセージ テンプレート
    
  •         `target-branch` - pull request のターゲット ブランチ
    
  •         `pull-request-branch-name` - ブランチの名前付けの構成
    

警告

エコシステム レベル (updates エントリ) でグループのみのキーを設定しようとすると、Dependabot によって構成エラーがスローされ、dependabot.yml ファイルの処理に失敗します。 これらのキーは multi-ecosystem-groups セクションでのみ指定する必要があります。

          **例:**

次の表は、次の例で Dependabot が Docker pull request のグループ レベルとエコシステム レベルの両方の値を結合する方法を示しています。

回答内容グループレベルの値エコシステムレベルの値結果
assignees@platform-team@docker-admin
          `@platform-team`、`@docker-admin`      |

| labels | infrastructure | dockercontainers | infrastructuredockercontainers|

YAML
multi-ecosystem-groups:
  infrastructure:
    assignees: ["@platform-team"]
    labels: ["infrastructure"]

updates:
  - package-ecosystem: "docker"
    assignees: ["@docker-admin"]
    labels: ["docker", "containers"]
    multi-ecosystem-group: "infrastructure"

ユース ケースと例

マルチエコシステム更新は、複数のパッケージ マネージャーを使い、それらの間で更新を調整するプロジェクトに特に役立ちます。 一般的なシナリオは次のとおりです。

インフラストラクチャ プロジェクト

          **シナリオ**: インフラストラクチャ コードには、Docker コンテナー、クラウド リソース用の Terraform、自動化用の Python スクリプトなど、複数のテクノロジを使っています。 インフラストラクチャ関連のすべての更新をグループ化して、レビューと配置の調整を容易にする必要があります。

          **これらをグループ化する理由**: 多くの場合、インフラストラクチャの変更はまとめて配置する必要があり、テクノロジごとに個別の PR があると調整のオーバーヘッドが発生します。
YAML
multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"  # Weekly updates to avoid disruption

updates:
  - package-ecosystem: "docker"
    directory: "/"
    patterns: ["nginx", "redis", "postgres"]
    multi-ecosystem-group: "infrastructure"
  - package-ecosystem: "terraform"
    directory: "/"
    patterns: ["aws", "terraform-*"]
    multi-ecosystem-group: "infrastructure"
  - package-ecosystem: "pip"
    directory: "/"
    patterns: ["boto3", "requests", "pyyaml"]
    multi-ecosystem-group: "infrastructure"
          **結果**: インフラストラクチャの自動化で使用される Docker イメージ、Terraform プロバイダー、Python の依存関係の更新を含む 1 週間ごとの pull request。

フルスタック アプリケーション

          **シナリオ**: React フロントエンドと Rails バックエンドを備えた Web アプリケーションがあります。 互換性を確保し、テストを効率化するために、フロントエンドとバックエンドの依存関係を一緒に更新する必要があります。

          **これらをグループ化する理由**: フロントエンドとバックエンドは相互に依存していることが多く、一緒に更新することで、アプリケーション スタック全体を一度にテストすることができます。
YAML
multi-ecosystem-groups:
  app-dependencies:
    schedule:
      interval: "daily"  # More frequent updates for application code

updates:
  - package-ecosystem: "npm"
    directory: "/frontend"
    patterns: ["react", "lodash", "@types/*"]  # Core frontend libraries and TypeScript types
    multi-ecosystem-group: "app-dependencies"
  - package-ecosystem: "bundler"
    directory: "/backend"
    patterns: ["rails", "pg", "sidekiq"]  # Core backend framework and database
    multi-ecosystem-group: "app-dependencies"
          **結果**: フロントエンドの JavaScript/TypeScript の更新とバックエンドの Ruby gem の更新の両方を含む毎日の PR により、完全なアプリケーションを一緒にテストできます。

クロスプラットフォーム ライブラリ

          **シナリオ**: 異なる言語間で同じプロトコルを使うライブラリまたはサービス (gRPC や Protocol Buffers など) を構築しています。 すべての実装間でライブラリのバージョンを同期する必要があります。

          **これらをグループ化する理由**: プロトコル ライブラリは、異なる言語実装間で互換性を保つ必要があるため、一緒に更新するとバージョンの不一致を防ぐことができます。
YAML
multi-ecosystem-groups:
  grpc-and-protobuf:
    schedule:
      interval: "daily"

updates:
  - package-ecosystem: "bundler"
    directory: "/grpc-proto-test/"
    patterns: ["grpc", "google-protobuf"]
    multi-ecosystem-group: "grpc-and-protobuf"
  - package-ecosystem: "npm"
    directory: "/grpc-proto-test/"
    patterns: ["@grpc/grpc-js", "google-protobuf"]
    multi-ecosystem-group: "grpc-and-protobuf"
          **結果**: 毎日の PR により、Ruby と Node.js gRPC ライブラリの同期状態を維持し、プロトコルの互換性に関する issue を防ぐことができます。

高度な構成の例

この包括的な例は、複雑なプロジェクトで、複数の更新戦略とキーのマージを含む複数のグループをどのように使用するかを示しています。

YAML
version: 2

multi-ecosystem-groups:
  infrastructure:
    schedule:
      interval: "weekly"
    assignees: ["@platform-team"]           # assign platform team
    labels: ["infrastructure", "dependencies"]
    milestone: 10                           # Track in milestone
    commit-message:
      prefix: "infra"
      include: "scope"

  # Application code updates - daily, with development team
  full-stack:
    schedule:
      interval: "daily"
    assignees: ["@full-stack-team"]         # assign to full-stack team
    labels: ["full-stack"]

updates:
  # Docker images - infrastructure group with additional docker expertise
  - package-ecosystem: "docker"
    directory: "/"
    patterns: ["nginx", "redis", "postgres"]
    assignees: ["@docker-admin"]            # adds to @platform-team (additive)
    labels: ["docker"]                      # adds to infrastructure, dependencies (additive)
    multi-ecosystem-group: "infrastructure"

  # Terraform - infrastructure group with terraform specialists
  - package-ecosystem: "terraform"
    directory: "/"
    patterns: ["aws", "terraform-*"]
    multi-ecosystem-group: "infrastructure"

  # Frontend - full-stack group with frontend focus
  - package-ecosystem: "npm"
    directory: "/frontend"
    patterns: ["react", "lodash", "@types/*"]
    labels: ["frontend"]                    # adds to full-stack (additive)
    multi-ecosystem-group: "full-stack"

  # Backend - full-stack group with backend specialist
  - package-ecosystem: "bundler"
    directory: "/backend"
    patterns: ["rails", "pg", "sidekiq"]
    assignees: ["@backend-dev"]             # adds to @full-stack-team (additive)
    multi-ecosystem-group: "full-stack"

この構成のしくみ

インフラストラクチャ PR

  • schedule: weekly
回答内容グループレベルの値エコシステムレベルの値結果
assignees@platform-team
          `@docker-admin` (Docker)、`@terraform-experts` (Terraform) | すべて結合 |

| labels | infrastructuredependencies | docker (Docker) | すべて結合 | | schedule | weekly | なし | 週次更新 | | milestone | 10 | なし | マイルストーン 10 で追跡 |

フル スタック PR

  • schedule: daily
回答内容グループレベルの値エコシステムレベルの値結果
assignees@full-stack-team
          `@backend-dev` (バックエンド) | すべて結合 |

| labels | full-stack | frontend (フロントエンド) | すべて結合 | | schedule | daily | なし | より頻繁な更新 |

このアプローチにより、関連するテクノロジ全体で一貫性のあるポリシーを維持しながら、各種類の更新に適切な担当者を確実に関与させることができます。

ベスト プラクティス

  •         **関連する依存関係をグループ化する**: 論理的に関連のあるエコシステムのみをグループ化します。
    
  •         **わかりやすい識別子を使う**: グループの目的を明確に示すグループ名を選びます。
    

参考資料

  •         [AUTOTITLE](/code-security/dependabot/working-with-dependabot/dependabot-options-reference)