Created
September 30, 2021 22:16
-
-
Save kmbarry1/5dc9f4a484a8a8bd7320091a4bb58f19 to your computer and use it in GitHub Desktop.
Automatically Create GitHub Repo Labels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paste in to console at at https://github.com/<org>/<repo_name>/labels: | |
[ | |
{ | |
"name": "Priority: Critical", | |
"description": null, | |
"color": "b60205" | |
}, | |
{ | |
"name": "Priority: High", | |
"description": null, | |
"color": "d93f0b" | |
}, | |
{ | |
"name": "Priority: Low", | |
"description": null, | |
"color": "94f230" | |
}, | |
{ | |
"name": "Priority: Medium", | |
"description": null, | |
"color": "fbca04" | |
}, | |
{ | |
"name": "Status: Approved", | |
"description": null, | |
"color": "0e8a16" | |
}, | |
{ | |
"name": "Status: Blocked", | |
"description": null, | |
"color": "e3ed78" | |
}, | |
{ | |
"name": "Status: On Hold", | |
"description": null, | |
"color": "e99695" | |
}, | |
{ | |
"name": "Status: Ready for Review", | |
"description": null, | |
"color": "0e8a16" | |
}, | |
{ | |
"name": "Status: Revisions Needed", | |
"description": null, | |
"color": "fef2c0" | |
}, | |
{ | |
"name": "Status: Work In Progress", | |
"description": null, | |
"color": "1d76db" | |
}, | |
{ | |
"name": "Type: Bug", | |
"description": null, | |
"color": "d93f0b" | |
}, | |
{ | |
"name": "Type: Enhancement", | |
"description": null, | |
"color": "bfdadc" | |
} | |
].forEach(function(label) { | |
addLabel(label) | |
}) | |
function updateLabel (label) { | |
var flag = false; | |
[].slice.call(document.querySelectorAll(".labels-list-item")) | |
.forEach(function(element) { | |
if (element.querySelector('.label-link').textContent.trim() === label.name) { | |
flag = true | |
element.querySelector('.js-edit-label').click() | |
element.querySelector('.js-new-label-name-input').value = label.name | |
element.querySelector('.js-new-label-description-input').value = label.description | |
element.querySelector('.js-new-label-color-input').value = '#' + label.color | |
element.querySelector('.js-edit-label-cancel ~ .btn-primary').click() | |
} | |
}) | |
return flag | |
} | |
function addNewLabel (label) { | |
document.querySelector('.js-new-label-name-input').value = label.name | |
document.querySelector('.js-new-label-description-input').value = label.description | |
document.querySelector('.js-new-label-color-input').value = '#' + label.color | |
document.querySelector('.js-details-target ~ .btn-primary').disabled = false | |
document.querySelector('.js-details-target ~ .btn-primary').click() | |
} | |
function addLabel (label) { | |
if (!updateLabel(label)) addNewLabel(label) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment