From 2c7487e2b4424f789d845ad2948865b13debee8b Mon Sep 17 00:00:00 2001 From: Zakary Timson Date: Tue, 16 Apr 2024 14:40:27 +0000 Subject: [PATCH] Add copy-labels.js --- copy-labels.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 copy-labels.js diff --git a/copy-labels.js b/copy-labels.js new file mode 100644 index 0000000..99fd4f2 --- /dev/null +++ b/copy-labels.js @@ -0,0 +1,23 @@ +#!/usr/local/bin bun + +const HOST = 'https://git.zakscode.com'; +const SOURCE = 'ztimson/template'; +const TARGET = 'ztimson/momentum'; +const TOKEN = 'd3da7314865bb8da08a474480e9924270362e456'; + +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}`); +});