You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-20Lines changed: 33 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ The normal flow is:
23
23
24
24
1. You run `Org-Label-Sync` manually.
25
25
2. It first calls `Config-Label_Sync`.
26
-
3.`Config-Label_Sync` reads the labels on this repository and rewrites `config/labels.jsonc` so the file matches the repo's current managed labels.
26
+
3.`Config-Label_Sync` reads the labels on this repository and rewrites `config/labels.jsonc` so the file matches the repo's current labels.
27
27
4. If that file changed, `Config-Label_Sync` commits and pushes the update.
28
28
5. That config change triggers `Validate-Configs`.
29
29
6.`Org-Label-Sync` then checks out the latest default branch, validates the config again, and syncs labels across the organization.
@@ -86,7 +86,7 @@ Example:
86
86
87
87
This is the managed label set that gets created or updated across the org.
88
88
89
-
It is normally maintained automatically by `Config-Label_Sync`, based on the labels currently present on this repository after excluding auto-pruned labels.
89
+
It is normally maintained automatically by `Config-Label_Sync`, based on the labels currently present on this repository.
90
90
91
91
Each label object uses:
92
92
@@ -108,21 +108,34 @@ Example:
108
108
109
109
### `config/auto-pruned-labels.jsonc`
110
110
111
-
This is the list of labels that should always be removed from synced repositories.
111
+
This is the list of exact labels that should be removed from synced repositories when they are not managed by `config/labels.jsonc`.
112
112
113
-
The starter file is prefilled with GitHub's default labels:
113
+
Each entry must include:
114
114
115
-
-`bug`
116
-
-`documentation`
117
-
-`duplicate`
118
-
-`enhancement`
119
-
-`good first issue`
120
-
-`help wanted`
121
-
-`invalid`
122
-
-`question`
123
-
-`wontfix`
115
+
-`name`
116
+
-`color`
117
+
-`description`
118
+
119
+
The starter file is prefilled with GitHub's default labels as exact specs:
120
+
121
+
```jsonc
122
+
[
123
+
{
124
+
"name":"bug",
125
+
"color":"d73a4a",
126
+
"description":"Something isn't working"
127
+
},
128
+
{
129
+
"name":"enhancement",
130
+
"color":"a2eeef",
131
+
"description":"New feature or request"
132
+
}
133
+
]
134
+
```
135
+
136
+
`Org-Label-Sync` only deletes a configured auto-pruned label when the target repository label has the same name casing, color, and description. A custom label such as `Enhancement`, or an `enhancement` label with a different description or color, is not deleted by this file.
124
137
125
-
If any of those labels exist on this repo, `Config-Label_Sync` excludes them from `labels.jsonc`. If they exist on target repos, `Org-Label-Sync` deletes them.
138
+
Managed labels are the source of truth. If a label exists in `config/labels.jsonc`, it is created or updated on target repositories and is not deleted by `config/auto-pruned-labels.jsonc`, even when it has the same name as an auto-pruned default.
126
139
127
140
### `config/repository-filter.jsonc`
128
141
@@ -173,8 +186,8 @@ What it does:
173
186
1. Checks out the default branch
174
187
2. Loads shared settings from `config/properties.jsonc`
175
188
3. Reads the current labels on the source repository
176
-
4.Removes any labels listed in `config/auto-pruned-labels.jsonc`
177
-
5.Rewrites`config/labels.jsonc` so it exactly matches the remaining labels
189
+
4.Rewrites `config/labels.jsonc` so it exactly matches the source repository labels
190
+
5.Validates`config/auto-pruned-labels.jsonc` so exact default-delete specs remain well-formed
178
191
6. Commits and pushes the change if the config was updated
179
192
180
193
This workflow is the bridge between "the labels on this repo right now" and "the managed config we sync elsewhere."
@@ -202,7 +215,7 @@ Validation includes:
202
215
- duplicate whitelist and blacklist detection
203
216
- invalid colors
204
217
- invalid repo names
205
-
-overlap detection between `labels.jsonc` and `auto-pruned-labels.jsonc`
218
+
-exact auto-pruned label shape validation
206
219
- validation for the shared config used by `Remove-Labels`
207
220
208
221
### `Org-Label-Sync`
@@ -228,7 +241,7 @@ What it does:
228
241
5. Discovers repos in the configured organization
229
242
6. Applies `config/repository-filter.jsonc`
230
243
7. Creates or updates labels from `config/labels.jsonc`
231
-
8. Deletes labels listed in `config/auto-pruned-labels.jsonc`
244
+
8. Deletes labels that exactly match entries in `config/auto-pruned-labels.jsonc` unless that label name is managed by `config/labels.jsonc`
232
245
9. Optionally deletes any other unmanaged labels if `delete_missing` or `deleteMissingByDefault` is enabled
233
246
10. If the run is not a dry run and at least one target repo changed, writes a changelog under `changelogs/YYYY-MM-DD/` and commits it with `[skip ci]`
234
247
@@ -300,7 +313,7 @@ That token needs enough access to:
300
313
1. Fork or clone this repository into the organization you want to manage.
301
314
2. Create the sync token secret in the repo.
302
315
3. Update `config/properties.jsonc` for your org and repo.
303
-
4. Adjust `config/auto-pruned-labels.jsonc` if you want a different always-delete list.
316
+
4. Adjust `config/auto-pruned-labels.jsonc` if you want different exact default-delete specs.
304
317
5. Configure `config/repository-filter.jsonc` for blacklist mode or whitelist mode.
305
318
6. Set the labels on this repository to the label set you want to manage.
306
319
7. Run `Config-Label_Sync` once if you want to populate `config/labels.jsonc` immediately.
@@ -310,5 +323,5 @@ That token needs enough access to:
310
323
311
324
-`labels.jsonc` starts empty until you define or sync labels on this repo
312
325
- all repos in the org are targeted unless excluded by `repository-filter.jsonc`
313
-
- GitHub default labels are auto-pruned by default
326
+
- GitHub default labels are auto-pruned by default only when they exactly match the stored name, color, and description and are not managed in `labels.jsonc`
314
327
- deleting unmanaged labels is off by default unless you enable it
assert(entry&&typeofentry==="object"&&!Array.isArray(entry),`Delete label at index ${index} must be an object.`);
98
+
assert(typeofentry.name==="string"&&entry.name.trim(),`Delete label at index ${index} is missing a valid name.`);
99
+
assert(typeofentry.color==="string"&&/^[0-9a-fA-F]{6}$/.test(normalizeColor(entry.color)),`Delete label "${entry.name}" must have a 6-character hex color.`);
100
+
assert(typeofentry.description==="string",`Delete label "${entry.name}" must include a string description.`);
`Synced ${managedLabels.length} managed labels from ${repository} into config/labels.jsonc after excluding ${deleteLabels.size}auto-pruned labels.`,
79
+
`Synced ${managedLabels.length} managed labels from ${repository} into config/labels.jsonc. Source labels take precedence over ${deleteLabels.length} exact auto-pruned label specs.`,
0 commit comments