|
| 1 | +--- |
| 2 | +title: Managing dependency updates |
| 3 | +shortTitle: Manage dependency updates |
| 4 | +intro: '{% data variables.copilot.copilot_chat_short %} can help you get set up with {% data variables.product.prodname_dependabot %} to streamline dependency updates.' |
| 5 | +versions: |
| 6 | + feature: copilot |
| 7 | +category: |
| 8 | + - 'Security analysis' |
| 9 | +complexity: |
| 10 | + - Simple |
| 11 | +octicon: code |
| 12 | +topics: |
| 13 | + - Copilot |
| 14 | +--- |
| 15 | + |
| 16 | +## Automate dependency updates |
| 17 | + |
| 18 | +### Example scenario |
| 19 | + |
| 20 | +Let's say your project depends on numerous libraries and packages. Vulnerable or outdated dependencies create security risks that can affect your project and others that rely on it. |
| 21 | + |
| 22 | +{% data variables.copilot.copilot_chat_short %} can help you get set up with {% data variables.product.prodname_dependabot %} security and version updates, so that your dependencies always remain on the most secure, and up-to-date versions. See [AUTOTITLE](/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates) and [AUTOTITLE](/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates). |
| 23 | + |
| 24 | +Before you begin, ensure that {% data variables.product.prodname_dependabot %} is fully enabled under your repository's "Settings." |
| 25 | +1. Under your "Code security" settings, ensure **{% data variables.product.prodname_dependabot_alerts %}** and **{% data variables.product.prodname_dependabot_security_updates %}** are both set to "Enabled." |
| 26 | +1. Create and commit an empty `.github/dependabot.yml` file to the repository. |
| 27 | + |
| 28 | +### Example prompt |
| 29 | + |
| 30 | +Make sure your repository is attached to the prompt for context. |
| 31 | + |
| 32 | +`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.).` |
| 33 | + |
| 34 | +`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.` |
| 35 | + |
| 36 | +`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.` |
| 37 | + |
| 38 | +### Example output |
| 39 | + |
| 40 | +{% data variables.copilot.copilot_chat_short %} analyzes your repository and writes the contents of the `dependabot.yml` configuration file for you, which tells {% data variables.product.prodname_dependabot %} which dependencies it needs to scan for. |
| 41 | + |
| 42 | +```yaml |
| 43 | +version: 2 |
| 44 | +updates: |
| 45 | + # Python (pip) |
| 46 | + - package-ecosystem: "pip" |
| 47 | + directory: "/" # Location of requirements.txt |
| 48 | + schedule: |
| 49 | + interval: "weekly" # Weekly updates are a good balance for libraries |
| 50 | + day: "sunday" |
| 51 | + time: "06:00" |
| 52 | + timezone: "UTC" |
| 53 | + open-pull-requests-limit: 5 |
| 54 | + allow: |
| 55 | + - dependency-type: "all" |
| 56 | + commit-message: |
| 57 | + prefix: "pip" |
| 58 | + labels: |
| 59 | + - "dependencies" |
| 60 | + - "python" |
| 61 | + ignore: |
| 62 | + - dependency-name: "pip" # Ignore pip self-updates |
| 63 | + |
| 64 | + # GitHub Actions |
| 65 | + - package-ecosystem: "github-actions" |
| 66 | + directory: "/" # Looks for workflow files under .github/workflows/ |
| 67 | + schedule: |
| 68 | + interval: "weekly" |
| 69 | + day: "sunday" |
| 70 | + time: "06:00" |
| 71 | + timezone: "UTC" |
| 72 | + open-pull-requests-limit: 5 |
| 73 | + commit-message: |
| 74 | + prefix: "actions" |
| 75 | + labels: |
| 76 | + - "dependencies" |
| 77 | + - "github-actions" |
| 78 | +``` |
| 79 | +
|
| 80 | +Once you've committed the `dependabot.yml` file to your repository, {% data variables.product.prodname_dependabot %} will begin to open pull requests against your repository, whenever a vulnerable or outdated dependency is detected. |
| 81 | + |
| 82 | +## Customize dependency management |
| 83 | + |
| 84 | +### Example scenario |
| 85 | + |
| 86 | +### Example scenario |
| 87 | + |
| 88 | +Let's say your team has been using the basic {% data variables.product.prodname_dependabot %} configuration for a few months, and you're getting lots of dependency update pull requests. However, you're finding that: |
| 89 | + |
| 90 | +* Pull requests are sitting un-reviewed because no one is automatically assigned. |
| 91 | +* You want pull requests to be automatically added to your team's project board via a label. |
| 92 | +* Your CI is getting overwhelmed with too many concurrent dependency pull requests. |
| 93 | +* You're getting updates for development dependencies that don't affect production. |
| 94 | + |
| 95 | +You want to customize your {% data variables.product.prodname_dependabot %} configuration to better fit your team's workflow, such as automatically assigning pull requests to the right team members, adding labels to add pull requests to project board, limiting the number of open pull requests, and focusing only on production dependencies. |
| 96 | + |
| 97 | +{% data variables.copilot.copilot_chat_short %} can write an updated `dependabot.yml` that better suits your team's needs. |
| 98 | + |
| 99 | +### Example prompt |
| 100 | + |
| 101 | +`I want to customize my pull requests for Dependabot security and version updates, so that:` |
| 102 | + |
| 103 | +`* Pull requests are automatically assigned to the team "octocat-reviewers."` |
| 104 | + |
| 105 | +`* The label "security-management" is automatically added to every pull request.` |
| 106 | + |
| 107 | +`* The number of open Dependabot PRs is limited.` |
| 108 | + |
| 109 | +`* Development dependencies are ignored.` |
| 110 | + |
| 111 | +`Draft an update to the dependabot.yml file in my repository that specifies these customization options.` |
| 112 | + |
| 113 | +> [!TIP] |
| 114 | +> * There are many customization options to explore. For more information, see [AUTOTITLE](/code-security/dependabot/dependabot-security-updates/customizing-dependabot-security-prs) and [AUTOTITLE](/code-security/dependabot/dependabot-version-updates/customizing-dependabot-prs). |
| 115 | +> * You can specify different customizations per package ecosystem. |
| 116 | + |
| 117 | +### Example output |
| 118 | + |
| 119 | +```yaml |
| 120 | +version: 2 |
| 121 | +updates: |
| 122 | + # Python (pip) |
| 123 | + - package-ecosystem: "pip" |
| 124 | + directory: "/" |
| 125 | + schedule: |
| 126 | + interval: "weekly" |
| 127 | + day: "sunday" |
| 128 | + time: "06:00" |
| 129 | + timezone: "UTC" |
| 130 | + open-pull-requests-limit: 5 |
| 131 | + allow: |
| 132 | + - dependency-type: "production" # Ignore development dependencies |
| 133 | + assignees: |
| 134 | + - "octocat-reviewers" # Assign PRs to the team |
| 135 | + labels: |
| 136 | + - "dependencies" |
| 137 | + - "security-management" # Custom label for all PRs |
| 138 | + - "python" |
| 139 | + commit-message: |
| 140 | + prefix: "pip" |
| 141 | + ignore: |
| 142 | + - dependency-name: "pip" |
| 143 | +``` |
0 commit comments