Skip to content

Instantly share code, notes, and snippets.

@coloredcow-admin
Last active January 5, 2023 08:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coloredcow-admin/36cdf1ebae802cc24180dcb2ca58961e to your computer and use it in GitHub Desktop.
Save coloredcow-admin/36cdf1ebae802cc24180dcb2ca58961e to your computer and use it in GitHub Desktop.
GitHub labels for repository
// how to run this script
// Step 1: Copy this gist.
// Step 2: Open the labels page in your GitHub repository where you want to set up the labels.
// Step 3: Open Browser Inspector tool and go to Console tab.
// Step 4: Paste the gist in the console and hit enter. The script will delete all the existing labels and create the new ones.
var labels = [
{
"name": "priority : critical",
"color": "b60205"
},
{
"name": "priority : high",
"color": "d93f0b"
},
{
"name": "priority : low",
"color": "0e8a16"
},
{
"name": "priority : medium",
"color": "fbca04"
},
{
"name": "status : acceptance testing",
"color": "006b75"
},
{
"name": "status : development",
"color": "ffffff"
},
{
"name": "status : ready for review",
"color": "bfd4f2"
},
{
"name": "status : ready to test",
"color": "fef2c0"
},
{
"name": "status : requirements and design",
"color": "d4c5f9"
},
{
"name": "status : reviewed",
"color": "c2e0c6"
},
{
"name": "type : bug",
"color": "fc2929"
},
{
"name": "type : enhancement",
"color": "84b6eb"
},
{
"name": "type : feature",
"color": "0052cc"
},
{
"name": "type : discussion",
"color": "cc317c"
},
{
"name": "story point: 0.5",
"description": "Task that can happen in 2 hours or less",
"color": "B6D686"
},
{
"name": "story point: 1",
"description": "Task that can happen in 2-4 hours",
"color": "B6D686"
},
{
"name": "story point: 2",
"description": "Task that can happen in 4-8 hours",
"color": "DFED06"
},
{
"name": "story point: 3",
"description": "Task that can happen in 8-16 hours - prefer breakdown",
"color": "F5F499"
},
{
"name": "story point: 5",
"description": "Task that can happen in 16-32 hours - requires breakdown",
"color": "C8914A"
},
{
"name": "story point: 8",
"description": "Task that can happen in 32 hours or more - requires breakdown",
"color": "C97543"
},
];
process();
function process() {
disableConfirmDialog();
deleteExistingLabels();
labels.forEach(async function(label) {
addNewLabel(label);
});
}
function disableConfirmDialog() {
window.confirm=function(){
return true;
};
}
function deleteExistingLabels() {
document.querySelectorAll('.js-delete-label button').forEach(function(button){
button.click();
});
}
function addNewLabel (label) {
document.querySelector('.js-new-label-name-input').value = label.name;
document.querySelector('.js-new-label-color-input').value = '#' + label.color;
if (label.description) {
document.querySelector('.js-new-label-description-input').value = label.description;
}
document.querySelector('.js-details-target-new-label').click();
document.querySelector('#new_label button[type="submit"]').disabled = false;
document.querySelector('#new_label button[type="submit"]').click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment