Skip to content

Commit ea64051

Browse files
mchammer01Copilot
andauthored
Dependabot can group updates by dependency name across multiple directories in a monorepo [GA] (#59726)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f7c5080 commit ea64051

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

content/code-security/reference/supply-chain-security/dependabot-options-reference.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ Parameters | Purpose |
281281
| `IDENTIFIER` | Define an identifier for the group to use in branch names and pull request titles. This must start and end with a letter, and can contain letters, pipes `\|`, underscores `_`, or hyphens `-`. |
282282
| `applies-to` | Specify which type of update the group applies to. When undefined, defaults to version updates. Supported values: `version-updates` or `security-updates`. |
283283
| `dependency-type` | Limit the group to a type. Supported values: `development` or `production`. |
284-
| `patterns` | Define one or more patterns to include dependencies with matching names. |
285284
| `exclude-patterns` | Define one or more patterns to exclude dependencies from the group. |
285+
| {% ifversion dependabot-updates-group-by %} |
286+
| `group-by` | Group updates across multiple directories. Supported value: `dependency-name`. |
287+
| {% endif %} |
288+
| `patterns` | Define one or more patterns to include dependencies with matching names. |
286289
| `update-types` | Limit the group to one or more semantic versioning levels. Supported values: `minor`, `patch`, and `major`. |
287290

288291
### `dependency-type` (`groups`)
@@ -294,6 +297,29 @@ By default, a group will include all types of dependencies.
294297
* Use `development` to include only dependencies in the "Development dependency group."
295298
* Use `production` to include only dependencies in the "Production dependency group."
296299

300+
{% ifversion dependabot-updates-group-by %}
301+
302+
### `group-by` (`groups`)
303+
304+
Use `groups.<group-name>.group-by` to specify how {% data variables.product.prodname_dependabot %} should group updates across multiple directories in a monorepo.
305+
306+
* **Type:** String
307+
* **Accepted values:** `dependency-name`
308+
* **Applies to:** Configurations with multiple directories specified
309+
310+
When set to `dependency-name`, {% data variables.product.prodname_dependabot %} will create a single pull request for each dependency update across all specified directories, rather than separate pull requests per directory.
311+
312+
**Limitations of cross-directory grouping**
313+
314+
When using `group-by: dependency-name`:
315+
* All directories must use the same package ecosystem (for example, all `npm` or all `bundler`)
316+
* Applies to **version updates only**
317+
* If directories have incompatible version constraints for a dependency, {% data variables.product.prodname_dependabot %} will create separate pull requests
318+
319+
For examples showing the use of `group-by`, see [AUTOTITLE](/code-security/tutorials/secure-your-dependencies/optimizing-pr-creation-version-updates#grouping-updates-across-directories-in-a-monorepo).
320+
321+
{% endif %}
322+
297323
### `patterns` and `exclude-patterns` (`groups`)
298324

299325
Both options support using `*` as a wild card to define matches with dependency names. If a dependency matches both a pattern and an exclude-pattern, then it is excluded from the group.

content/code-security/tutorials/secure-your-dependencies/optimizing-pr-creation-version-updates.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ See also [`cooldown`](/code-security/dependabot/working-with-dependabot/dependab
110110

111111
## Prioritizing meaningful updates
112112

113+
### Grouping related dependencies together
114+
113115
You can use `groups` to consolidate updates for multiple dependencies into a single pull request. This helps you focus your review time on higher risk updates, and minimize the time spent reviewing minor version updates. For example, you can combine updates for minor or patch updates for development dependencies into a single pull request, and have a dedicated group for security or version updates that impact a key area of your codebase.
114116

115117
You must configure groups per individual package ecosystem, then you can create multiple groups per package ecosystem using a combination of criteria:
@@ -124,3 +126,36 @@ To see all supported values for each criterion, see [`groups`](/code-security/de
124126
The below examples present several different methods to create groups of dependencies using the criteria.
125127

126128
{% data reusables.dependabot.dependabot-version-updates-groups-yaml-example %}
129+
130+
{% ifversion dependabot-updates-group-by %}
131+
132+
### Grouping updates across directories in a monorepo
133+
134+
If you manage a monorepo with multiple directories that share common dependencies, you can reduce the number of pull requests for version updates by grouping updates by dependency name across all directories.
135+
136+
When you configure {% data variables.product.prodname_dependabot %} to monitor multiple directories and enable grouping by dependency name, {% data variables.product.prodname_dependabot %} will:
137+
* Create a single pull request for each dependency update that affects multiple directories
138+
* Update the same dependency to the same version across all directories in one operation
139+
* Reduce the number of pull requests you need to review
140+
* Minimize CI/CD costs by running tests once instead of per directory
141+
142+
For more information, see [`group-by`](/code-security/reference/supply-chain-security/dependabot-options-reference#group-by-groups).
143+
144+
This configuration example groups updates by dependency name across the `/frontend`, `/admin-panel`, and `/mobile-app` directories. If `lodash` needs to be updated in all three directories, {% data variables.product.prodname_dependabot %} will create a single pull request named "Bump lodash in monorepo-dependencies group" that updates `lodash` in all three locations.
145+
146+
```yaml
147+
version: 2
148+
updates:
149+
- package-ecosystem: "npm"
150+
directories:
151+
- "/frontend"
152+
- "/admin-panel"
153+
- "/mobile-app"
154+
schedule:
155+
interval: "weekly"
156+
groups:
157+
monorepo-dependencies:
158+
group-by: dependency-name
159+
```
160+
161+
{% endif %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reference: Issue #20890 - Dependabot can group updates by dependency name across multiple directories in a monorepo [GA]
2+
versions:
3+
fpt: '*'
4+
ghec: '*'
5+
ghes: '>= 3.21'

0 commit comments

Comments
 (0)