How to copy Labels from source repo to dest repo
Open the "Labels" tab in your GitHub source repo and paste this in the browser js console:
var labels = [];
[].slice.call(document.querySelectorAll(".js-label-link"))
.forEach(function(element) {
labels.push({
name: element.textContent.trim(),
// using style.backgroundColor might returns "rgb(...)"
color: element.getAttribute("style")
.replace("background-color:", "")
.replace(/color:.*/,"")
.trim()
// github wants hex code only without # or ;
.replace(/^#/, "")
.replace(/;$/, "")
.trim(),
})
})
console.log(JSON.stringify(labels, null, 2))
Copy the labels and create a conf.json
file
[{
"name": "Approved",
"color": "62d153"
}, {
"name": "Ready for Review",
"color": "FF8C00"
}, {
"name": "Under Development",
"color": "cfd3d7"
}, {
"name": "Under Review",
"color": "e4e669"
}, {
"name": "Under Testing",
"color": "bfd4f2"
}]
Install npm package
npm install github-labels -g
Import labels to desired repo
labels -c conf.json -h github.company-dns -p /api/v3 -t <enter-token> org/repo