Files
snippits/copy-labels.js
2026-06-03 01:17:54 -04:00

24 lines
902 B
JavaScript

#!/usr/local/bin bun
const HOST = 'https://git.zakscode.com';
const SOURCE = 'ztimson/template';
const TARGET = 'ztimson/momentum';
const TOKEN = '';
console.log(`Copying from: ${HOST}/api/v1/repos/${SOURCE}/labels`);
console.log(`To: ${HOST}/api/v1/repos/${TARGET}/labels`);
const labels = await (await fetch(`${HOST}/api/v1/repos/${SOURCE}/labels?token=${TOKEN}`)).json();
labels.forEach(async l => {
console.log(`Adding: ${l['name']}`);
const resp = await fetch(`${HOST}/api/v1/repos/${TARGET}/labels?token=${TOKEN}`, {method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: l['name'],
description: l['description'],
color: l['color'],
exclusive: l['exclusive'],
})});
if(!resp.ok) console.error(`Failed: ${resp.status} - ${resp.statusText}`);
});