依存関係の更新を自動化する
シナリオ例
たとえば、projectは多数のライブラリとパッケージに依存しているとします。 脆弱または古い依存関係により、projectやそれに依存する他のユーザーに影響を与える可能性があるセキュリティ リスクが発生します。
Copilot チャット を使うと、Dependabot のセキュリティとバージョンの更新を設定できるため、依存関係を常に最も安全で最新のバージョンに保つことができます。 「Dependabot のセキュリティ アップデート」と「GitHub Dependabot のバージョンアップデートについて」を参照してください。
始める前に、リポジトリの [Settings] で Dependabot が完全に有効になっていることを確認します。
- [Code security] 設定で、Dependabot alerts と Dependabot security updates の両方が [Enabled] に設定されていることを確認します。
- 空の
.github/dependabot.ymlファイルを作成してリポジトリにコミットします。
プロンプトの例
リポジトリがコンテキストのプロンプトに接続されていることを確認します。
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.
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.
出力例
Copilot チャット はリポジトリを分析し、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 requests を、ラベルを介してチームのproject ボードに自動的に追加する必要があります。
- 同時依存関係の pull request が多すぎるため、CI が過負荷になっています。
- あなたは運用環境に影響を与えない開発依存関係の更新を取得しています。
Dependabot 構成をカスタマイズして、チームのワークフローにより適合させたいと考えています。たとえば、適切なチームメンバーに pull requests を自動的に割り当て、pull requests をプロジェクト ボードに追加するためのラベルを追加し、開いている pull requests の数を制限し、本番環境の依存関係のみに焦点を当てることができます。
Copilot チャット を使って、チームのニーズにより適した更新版の dependabot.yml を作成できます。
プロンプトの例
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.
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.
ヒント
- 探索できるカスタマイズ オプションは多数あります。 詳細については、「Dependabot セキュリティ更新プログラム用に pull request をカスタマイズする」および「実際のプロセスに合わせて Dependabot pull request をカスタマイズする」を参照してください。
- パッケージ エコシステムごとに異なるカスタマイズを指定できます。
出力例
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"