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
You'll need [Node.js][node] 12+ installed to run GitHub Label Sync. You'll also need a GitHub access token ready so that the tool will have access to your repositories. You can [generate an access token here][access-tokens], be sure to allow the "repo" scope.
15
+
## Requirements
22
16
17
+
You'll need [Node.js][node] 20+ installed to run GitHub Label Sync. You'll also need a GitHub access token ready so that the tool will have access to your repositories. You can [generate an access token here][access-tokens], be sure to allow the "repo" scope.
23
18
24
-
Command-Line Interface
25
-
----------------------
19
+
## Command-Line Interface
26
20
27
21
Install GitHub Label Sync globally with [npm][npm]:
28
22
@@ -75,9 +69,7 @@ Normally any additional labels found on the repo are deleted. Run GitHub label s
Install GitHub Label Sync with [npm][npm] or add to your `package.json`:
83
75
@@ -97,13 +89,13 @@ Run GitHub Label Sync on a repo ([passing in options](#configuration)):
97
89
98
90
```js
99
91
githubLabelSync({
100
-
accessToken:'xxxxxx',
101
-
repo:'myname/myrepo',
102
-
labels: [
103
-
// label config
104
-
]
92
+
accessToken:'xxxxxx',
93
+
repo:'myname/myrepo',
94
+
labels: [
95
+
// label config
96
+
]
105
97
}).then((diff) => {
106
-
console.log(diff);
98
+
console.log(diff);
107
99
});
108
100
```
109
101
@@ -113,108 +105,101 @@ When the promise resolves successfully, its value will be set to a diff between
113
105
114
106
```js
115
107
[
116
-
// This is a "missing" diff, it indicates that a label
117
-
// present in your local config is not present on GitHub.
118
-
{
119
-
name:'local-label-name',
120
-
type:'missing',
121
-
actual:null,
122
-
expected: {
123
-
name:'local-label-name',
124
-
color:'ff0000'
125
-
}
126
-
},
127
-
// This is a "changed" diff, it indicates that a label
128
-
// present on GitHub has diverged from your local config.
129
-
// This could mean that either somebody has modified the
130
-
// label manually on GitHub, or the local config has
131
-
// been updated.
132
-
{
133
-
name:'local-label-name',
134
-
type:'changed',
135
-
actual: {
136
-
name:'remote-label-name',
137
-
color:'00ff00'
138
-
},
139
-
expected: {
140
-
name:'local-label-name',
141
-
color:'ff0000'
142
-
}
143
-
},
144
-
// This is an "added" diff, it indicates that a label
145
-
// is present on GitHub but not in your local config.
146
-
{
147
-
name:'remote-label-name',
148
-
type:'added',
149
-
actual: {
150
-
name:'remote-label-name',
151
-
color:'ff0000'
152
-
},
153
-
expected:null
154
-
}
155
-
]
108
+
// This is a "missing" diff, it indicates that a label
109
+
// present in your local config is not present on GitHub.
110
+
{
111
+
name:'local-label-name',
112
+
type:'missing',
113
+
actual:null,
114
+
expected: {
115
+
name:'local-label-name',
116
+
color:'ff0000'
117
+
}
118
+
},
119
+
// This is a "changed" diff, it indicates that a label
120
+
// present on GitHub has diverged from your local config.
121
+
// This could mean that either somebody has modified the
122
+
// label manually on GitHub, or the local config has
123
+
// been updated.
124
+
{
125
+
name:'local-label-name',
126
+
type:'changed',
127
+
actual: {
128
+
name:'remote-label-name',
129
+
color:'00ff00'
130
+
},
131
+
expected: {
132
+
name:'local-label-name',
133
+
color:'ff0000'
134
+
}
135
+
},
136
+
// This is an "added" diff, it indicates that a label
137
+
// is present on GitHub but not in your local config.
138
+
{
139
+
name:'remote-label-name',
140
+
type:'added',
141
+
actual: {
142
+
name:'remote-label-name',
143
+
color:'ff0000'
144
+
},
145
+
expected:null
146
+
}
147
+
];
156
148
```
157
149
158
-
159
-
Label Config File
160
-
----------
150
+
## Label Config File
161
151
162
152
The labels to sync with are defined as an array in either JavaScript, JSON or YAML. The array must contain only label objects, which look like this:
163
153
164
154
As JSON:
165
155
166
156
```json
167
157
{
168
-
"name": "mylabel",
169
-
"color": "ff0000",
170
-
"aliases": [],
171
-
"description": "optional description",
172
-
"delete": false
158
+
"name": "mylabel",
159
+
"color": "ff0000",
160
+
"aliases": [],
161
+
"description": "optional description",
162
+
"delete": false
173
163
}
174
164
```
175
165
176
166
As YAML:
177
167
178
168
```yaml
179
169
- name: mylabel
180
-
color: "ff0000"
170
+
color: 'ff0000'
181
171
aliases: []
182
172
description: optional description
183
173
delete: false
184
174
```
185
175
186
-
- The `name` property refers to the label name.
187
-
- The `color` property should be a hex code, with or without the leading `#`.
188
-
- The `delete` property is optional. When set to `true`, matches for this label will _always_ be deleted. This can be used in conjunction with [allowAddedLabels](#allowaddedlabels) to flag specific labels for deletion while leaving non-specified labels intact. Defaults to `false`.
176
+
- The `name` property refers to the label name.
177
+
- The `color` property should be a hex code, with or without the leading `#`.
178
+
- The `delete` property is optional. When set to `true`, matches for this label will _always_ be deleted. This can be used in conjunction with [allowAddedLabels](#allowaddedlabels) to flag specific labels for deletion while leaving non-specified labels intact. Defaults to `false`.
189
179
190
180
The `aliases` property is optional. When GitHub Label Sync is determining whether to update or delete/create a label it will use the aliases property to prevent used labels from being deleted.
191
181
192
182
For example, given the following config, GitHub Label Sync will look for labels on GitHub named either "feature" or "enhancement" then _update_ them to match the newer config rather than deleting them.
193
183
194
184
```json
195
185
{
196
-
"name": "type: feature",
197
-
"color": "00ff00",
198
-
"aliases": [
199
-
"enhancement",
200
-
"feature"
201
-
]
186
+
"name": "type: feature",
187
+
"color": "00ff00",
188
+
"aliases": ["enhancement", "feature"]
202
189
}
203
190
```
204
191
205
192
You can find a full example label configuration in this repository ([JSON](labels.json) / [YAML](labels.yml)).
206
193
207
-
208
-
Configuration
209
-
-------------
194
+
## Configuration
210
195
211
196
### `accessToken`
212
197
213
198
_String_. The [GitHub access token][access-tokens] to use when fetching/updating labels. This must be an access token that has permission to write to the repository you want to sync labels with.
214
199
215
200
```js
216
201
githubLabelSync({
217
-
accessToken: 'xxxxxx'
202
+
accessToken: 'xxxxxx'
218
203
});
219
204
```
220
205
@@ -231,7 +216,7 @@ _Boolean_. Whether to allow labels on GitHub which are not specified in your [la
231
216
232
217
```js
233
218
githubLabelSync({
234
-
allowAddedLabels: true
219
+
allowAddedLabels: true
235
220
});
236
221
```
237
222
@@ -247,7 +232,7 @@ _Boolean_. Whether to perform a dry run, only making safe "read" requests to the
247
232
248
233
```js
249
234
githubLabelSync({
250
-
dryRun: true
235
+
dryRun: true
251
236
});
252
237
```
253
238
@@ -263,7 +248,7 @@ _Array_. Your label configuration. See the section on [label config file](#label
263
248
264
249
```js
265
250
githubLabelSync({
266
-
labels: []
251
+
labels: []
267
252
});
268
253
```
269
254
@@ -275,7 +260,7 @@ _String_. The GitHub repo to sync labels to. This should include the user and re
275
260
276
261
```js
277
262
githubLabelSync({
278
-
repo: 'Financial-Times/ft-origami'
263
+
repo: 'Financial-Times/ft-origami'
279
264
});
280
265
```
281
266
@@ -285,9 +270,7 @@ The command-line accepts the repo as an argument after the options:
285
270
github-label-sync Financial-Times/ft-origami
286
271
```
287
272
288
-
289
-
Contributing
290
-
------------
273
+
## Contributing
291
274
292
275
To contribute to GitHub Label Sync, clone this repo locally and commit your code on a separate branch.
293
276
@@ -300,15 +283,11 @@ npm run test-unit # run the unit tests
300
283
npm run test-coverage # run the unit tests with coverage reporting
301
284
```
302
285
303
-
304
-
License
305
-
-------
286
+
## License
306
287
307
288
This software is published by the Financial Times under the [MIT licence][license].
0 commit comments