Skip to main content

依存関係の更新の管理

コパイロットチャット は、依存関係の更新を効率化するために Dependabot を設定するのに役立ちます。

依存関係の更新を自動化する

サンプル シナリオ

プロジェクトが多数のライブラリとパッケージに依存しているとします。 脆弱な依存関係や古い依存関係は、プロジェクトやそれに依存する他のプロジェクトに影響を与えるようなセキュリティ リスクを生み出します。

コパイロットチャット は、 Dependabot のセキュリティとバージョンの更新プログラムを設定するのに役立ちます。そのため、依存関係は常に最も安全で、up-to-date バージョンに維持されます。 「Dependabot のセキュリティ アップデート」と「GitHub Dependabot のバージョンアップデートについて」を参照してください。

開始する前に、リポジトリの [設定] で Dependabot が完全に有効になっていることを確認します。

  1. [コード セキュリティ] 設定で、 Dependabot alertsDependabot security updates の両方が [有効] に設定されていることを確認します。
  2. 空の .github/dependabot.yml ファイルを作成してリポジトリにコミットします。

プロンプトの例

リポジトリがコンテキストのプロンプトに接続されていることを確認します。

Copilot prompt
Analyze the codebase and project structure of this repository. Detect all package managers and package ecosystems in use, including their respective locations (e.g., npm, yarn, pip, maven, gradle, composer, github-actions, etc.).

For each detected ecosystem, create a configuration entry in a single, top-level .github/dependabot.yml file that enables security and version updates on a reasonable schedule. Use the recommended best practices for each ecosystem. Clearly specify the directory for each ecosystem detected. If multiple ecosystems or multiple directories are present, include them all in the configuration.

In the output, include any notes on the configuration or best practices, as well as next steps that include how to commit the dependabot.yml file to the repository via the GitHub web browser and how to check that Dependabot version updates and Dependabot security updates are enabled.

サンプルの出力

コパイロットチャット はリポジトリを分析し、 dependabot.yml 構成ファイルの内容を書き込みます。これによって、スキャンする必要がある依存関係 Dependabot が示されます。

version: 2
updates:
  # Python (pip)
  - package-ecosystem: "pip"
    directory: "/"                     # Location of requirements.txt
    schedule:
      interval: "weekly"               # Weekly updates are a good balance for libraries
      day: "sunday"
      time: "06:00"
      timezone: "UTC"
    open-pull-requests-limit: 5
    allow:
      - dependency-type: "all"
    commit-message:
      prefix: "pip"
    labels:
      - "dependencies"
      - "python"
    ignore:
      - dependency-name: "pip"         # Ignore pip self-updates

  # GitHub Actions
  - package-ecosystem: "github-actions"
    directory: "/"                     # Looks for workflow files under .github/workflows/
    schedule:
      interval: "weekly"
      day: "sunday"
      time: "06:00"
      timezone: "UTC"
    open-pull-requests-limit: 5
    commit-message:
      prefix: "actions"
    labels:
      - "dependencies"
      - "github-actions"

dependabot.yml ファイルをリポジトリにコミットすると、Dependabotは、脆弱または古い依存関係が検出されるたびに、リポジトリに対する pull request を開き始めます。

依存関係管理をカスタマイズする

サンプル シナリオ

たとえば、チームが数か月間基本的な Dependabot 構成を使用しており、依存関係の更新のプル要求が多数発生しているとします。 ただし、あなたは次のことがわかっています。

  • 誰も自動で担当者にされないため、プルリクエストは未レビューのまま放置されています。
  • あなたは、Pull request をラベル経由でチームのプロジェクト ボードに自動的に追加したいと考えています。
  • 同時依存関係の pull request が多すぎるため、CI が過負荷になっています。
  • あなたは運用環境に影響を与えない開発依存関係の更新を取得しています。

適切なチーム メンバーに pull request を自動的に割り当てる、プロジェクト ボードに pull request を追加するラベルを追加する、開いている pull request の数を制限する、運用環境の依存関係のみに焦点を当てるなど、チームのワークフローに合わせて Dependabot 構成をカスタマイズする必要があります。

コパイロットチャット は、チームのニーズに適した更新された dependabot.yml を記述できます。

プロンプトの例

Copilot prompt
I want to customize my pull requests for Dependabot security and version updates, so that:

* Pull requests are automatically assigned to the team "octocat-reviewers."
* The label "security-management" is automatically added to every pull request.
* The number of open Dependabot PRs is limited.
* Development dependencies are ignored.

Draft an update to the dependabot.yml file in my repository that specifies these customization options.

ヒント

サンプルの出力

version: 2
updates:
  # Python (pip)
  - package-ecosystem: "pip"
    directory: "/"
    schedule:
      interval: "weekly"
      day: "sunday"
      time: "06:00"
      timezone: "UTC"
    open-pull-requests-limit: 5
    allow:
      - dependency-type: "production"     # Ignore development dependencies
    assignees:
      - "octocat-reviewers"               # Assign PRs to the team
    labels:
      - "dependencies"
      - "security-management"             # Custom label for all PRs
      - "python"
    commit-message:
      prefix: "pip"
    ignore:
      - dependency-name: "pip"