Skip to content

Commit 53a1c75

Browse files
committed
Add include/exclude repo filters to team settings
Team entries are filtered by the same Diffable include/exclude logic that collaborators use, but unlike collaborators those keys were never part of the TeamSettings schema or documented, so editors and linters can't validate them. Mirror the CollaboratorSettings allOf pattern to declare include and exclude on TeamSettings, document both in the teams guide with examples, add a sample, and cover the filter path with unit tests. No runtime changes.
1 parent 4dac294 commit 53a1c75

9 files changed

Lines changed: 568 additions & 276 deletions

File tree

docs/github-settings/4. teams.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,33 @@ teams:
4848
permission: maintain
4949
```
5050
51+
</td></tr>
52+
<tr><td>
53+
<p>&emsp;<code>exclude</code><span style="color:gray;">&emsp;<i>array</i>&emsp;</span></p>
54+
<p>Exclude a list of repos for this team. The team is applied to every repo in scope except those whose names match one of these glob patterns.</p>
55+
</td><td style="vertical-align:top">
56+
57+
```yaml
58+
teams:
59+
- name: SuperFriends
60+
permission: maintain
61+
exclude:
62+
- secret-repo
63+
```
64+
65+
</td></tr>
66+
<tr><td>
67+
<p>&emsp;<code>include</code><span style="color:gray;">&emsp;<i>array</i>&emsp;</span></p>
68+
<p>Include a list of repos for this team. The team is applied only to repos whose names match one of these glob patterns.</p>
69+
</td><td style="vertical-align:top">
70+
71+
```yaml
72+
teams:
73+
- name: SuperFriends
74+
permission: maintain
75+
include:
76+
- public-*
77+
```
78+
5179
</td></tr>
5280
</table>

docs/sample-settings/settings.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ teams:
161161
- name: globalteam
162162
permission: push
163163
visibility: closed
164+
- name: docs-team
165+
permission: pull
166+
# You can include a list of repos for this team and only those repos would have this team
167+
include:
168+
- actions-demo
169+
- name: ops-team
170+
permission: push
171+
# You can exclude a list of repos for this team and all repos except these repos would have this team
172+
exclude:
173+
- actions-demo
164174

165175
# Branch protection rules
166176
# See https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2026-03-10#update-branch-protection for available options

schema/dereferenced/repos.json

Lines changed: 134 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -400,53 +400,76 @@
400400
"type": "array",
401401
"items": {
402402
"description": "A team entry",
403-
"type": "object",
404-
"properties": {
405-
"name": {
406-
"type": "string",
407-
"description": "The name of the team."
408-
},
409-
"description": {
410-
"type": "string",
411-
"description": "The description of the team."
412-
},
413-
"maintainers": {
414-
"type": "array",
415-
"description": "List GitHub usernames for organization members who will become team maintainers.",
416-
"items": {
417-
"type": "string"
418-
}
419-
},
420-
"repo_names": {
421-
"type": "array",
422-
"description": "The full name (e.g., \"organization-name/repository-name\") of repositories to add the team to.",
423-
"items": {
424-
"type": "string"
425-
}
426-
},
427-
"privacy": {
428-
"type": "string",
429-
"description": "The level of privacy this team should have. The options are: \n**For a non-nested team:** \n * `secret` - only visible to organization owners and members of this team. \n * `closed` - visible to all members of this organization. \nDefault: `secret` \n**For a parent or child team:** \n * `closed` - visible to all members of this organization. \nDefault for child team: `closed`",
430-
"enum": [
431-
"secret",
432-
"closed"
433-
]
434-
},
435-
"notification_setting": {
436-
"type": "string",
437-
"description": "The notification setting the team has chosen. The options are: \n * `notifications_enabled` - team members receive notifications when the team is @mentioned. \n * `notifications_disabled` - no one receives notifications. \nDefault: `notifications_enabled`",
438-
"enum": [
439-
"notifications_enabled",
440-
"notifications_disabled"
403+
"allOf": [
404+
{
405+
"type": "object",
406+
"properties": {
407+
"name": {
408+
"type": "string",
409+
"description": "The name of the team."
410+
},
411+
"description": {
412+
"type": "string",
413+
"description": "The description of the team."
414+
},
415+
"maintainers": {
416+
"type": "array",
417+
"description": "List GitHub usernames for organization members who will become team maintainers.",
418+
"items": {
419+
"type": "string"
420+
}
421+
},
422+
"repo_names": {
423+
"type": "array",
424+
"description": "The full name (e.g., \"organization-name/repository-name\") of repositories to add the team to.",
425+
"items": {
426+
"type": "string"
427+
}
428+
},
429+
"privacy": {
430+
"type": "string",
431+
"description": "The level of privacy this team should have. The options are: \n**For a non-nested team:** \n * `secret` - only visible to organization owners and members of this team. \n * `closed` - visible to all members of this organization. \nDefault: `secret` \n**For a parent or child team:** \n * `closed` - visible to all members of this organization. \nDefault for child team: `closed`",
432+
"enum": [
433+
"secret",
434+
"closed"
435+
]
436+
},
437+
"notification_setting": {
438+
"type": "string",
439+
"description": "The notification setting the team has chosen. The options are: \n * `notifications_enabled` - team members receive notifications when the team is @mentioned. \n * `notifications_disabled` - no one receives notifications. \nDefault: `notifications_enabled`",
440+
"enum": [
441+
"notifications_enabled",
442+
"notifications_disabled"
443+
]
444+
},
445+
"parent_team_id": {
446+
"type": "integer",
447+
"description": "The ID of a team to set as the parent team."
448+
}
449+
},
450+
"required": [
451+
"name"
441452
]
442453
},
443-
"parent_team_id": {
444-
"type": "integer",
445-
"description": "The ID of a team to set as the parent team."
454+
{
455+
"type": "object",
456+
"properties": {
457+
"exclude": {
458+
"description": "You can exclude a list of repos for this team and all repos except these repos would have this team",
459+
"type": "array",
460+
"items": {
461+
"type": "string"
462+
}
463+
},
464+
"include": {
465+
"description": "You can include a list of repos for this team and only those repos would have this team",
466+
"type": "array",
467+
"items": {
468+
"type": "string"
469+
}
470+
}
471+
}
446472
}
447-
},
448-
"required": [
449-
"name"
450473
]
451474
}
452475
},
@@ -1214,53 +1237,76 @@
12141237
},
12151238
"TeamSettings": {
12161239
"description": "A team entry",
1217-
"type": "object",
1218-
"properties": {
1219-
"name": {
1220-
"type": "string",
1221-
"description": "The name of the team."
1222-
},
1223-
"description": {
1224-
"type": "string",
1225-
"description": "The description of the team."
1226-
},
1227-
"maintainers": {
1228-
"type": "array",
1229-
"description": "List GitHub usernames for organization members who will become team maintainers.",
1230-
"items": {
1231-
"type": "string"
1232-
}
1233-
},
1234-
"repo_names": {
1235-
"type": "array",
1236-
"description": "The full name (e.g., \"organization-name/repository-name\") of repositories to add the team to.",
1237-
"items": {
1238-
"type": "string"
1239-
}
1240-
},
1241-
"privacy": {
1242-
"type": "string",
1243-
"description": "The level of privacy this team should have. The options are: \n**For a non-nested team:** \n * `secret` - only visible to organization owners and members of this team. \n * `closed` - visible to all members of this organization. \nDefault: `secret` \n**For a parent or child team:** \n * `closed` - visible to all members of this organization. \nDefault for child team: `closed`",
1244-
"enum": [
1245-
"secret",
1246-
"closed"
1247-
]
1248-
},
1249-
"notification_setting": {
1250-
"type": "string",
1251-
"description": "The notification setting the team has chosen. The options are: \n * `notifications_enabled` - team members receive notifications when the team is @mentioned. \n * `notifications_disabled` - no one receives notifications. \nDefault: `notifications_enabled`",
1252-
"enum": [
1253-
"notifications_enabled",
1254-
"notifications_disabled"
1240+
"allOf": [
1241+
{
1242+
"type": "object",
1243+
"properties": {
1244+
"name": {
1245+
"type": "string",
1246+
"description": "The name of the team."
1247+
},
1248+
"description": {
1249+
"type": "string",
1250+
"description": "The description of the team."
1251+
},
1252+
"maintainers": {
1253+
"type": "array",
1254+
"description": "List GitHub usernames for organization members who will become team maintainers.",
1255+
"items": {
1256+
"type": "string"
1257+
}
1258+
},
1259+
"repo_names": {
1260+
"type": "array",
1261+
"description": "The full name (e.g., \"organization-name/repository-name\") of repositories to add the team to.",
1262+
"items": {
1263+
"type": "string"
1264+
}
1265+
},
1266+
"privacy": {
1267+
"type": "string",
1268+
"description": "The level of privacy this team should have. The options are: \n**For a non-nested team:** \n * `secret` - only visible to organization owners and members of this team. \n * `closed` - visible to all members of this organization. \nDefault: `secret` \n**For a parent or child team:** \n * `closed` - visible to all members of this organization. \nDefault for child team: `closed`",
1269+
"enum": [
1270+
"secret",
1271+
"closed"
1272+
]
1273+
},
1274+
"notification_setting": {
1275+
"type": "string",
1276+
"description": "The notification setting the team has chosen. The options are: \n * `notifications_enabled` - team members receive notifications when the team is @mentioned. \n * `notifications_disabled` - no one receives notifications. \nDefault: `notifications_enabled`",
1277+
"enum": [
1278+
"notifications_enabled",
1279+
"notifications_disabled"
1280+
]
1281+
},
1282+
"parent_team_id": {
1283+
"type": "integer",
1284+
"description": "The ID of a team to set as the parent team."
1285+
}
1286+
},
1287+
"required": [
1288+
"name"
12551289
]
12561290
},
1257-
"parent_team_id": {
1258-
"type": "integer",
1259-
"description": "The ID of a team to set as the parent team."
1291+
{
1292+
"type": "object",
1293+
"properties": {
1294+
"exclude": {
1295+
"description": "You can exclude a list of repos for this team and all repos except these repos would have this team",
1296+
"type": "array",
1297+
"items": {
1298+
"type": "string"
1299+
}
1300+
},
1301+
"include": {
1302+
"description": "You can include a list of repos for this team and only those repos would have this team",
1303+
"type": "array",
1304+
"items": {
1305+
"type": "string"
1306+
}
1307+
}
1308+
}
12601309
}
1261-
},
1262-
"required": [
1263-
"name"
12641310
]
12651311
},
12661312
"MilestoneSettings": {

0 commit comments

Comments
 (0)