From 9163141f86be72d25d878aafcc763d6c6e09a8d3 Mon Sep 17 00:00:00 2001 From: Martin M Date: Mon, 25 Dec 2023 15:41:01 +0100 Subject: [PATCH] more updates (#3119) --- lib/common.js | 8 ++++---- lib/stableBrandNewReminder.js | 31 +++++++++++++++++-------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/common.js b/lib/common.js index 5531766ed..6ff376d49 100644 --- a/lib/common.js +++ b/lib/common.js @@ -43,12 +43,12 @@ function getLabels(prID) { .then(response => response.data ) } -function createLabel(label, name, description, color) { +function createLabel(name, description, color) { return axios.post(`https://api.github.com/repos/ioBroker/ioBroker.repositories/labels`, { - "name": name, - "description": description, - "color": color + 'name': `${name}`, + 'description': `${description}`, + 'color': `${color}` }, { headers: { diff --git a/lib/stableBrandNewReminder.js b/lib/stableBrandNewReminder.js index 1c0ba2ce3..ce81d328d 100644 --- a/lib/stableBrandNewReminder.js +++ b/lib/stableBrandNewReminder.js @@ -1,9 +1,10 @@ 'use strict'; const { addLabel, + createLabel, + getLabels, getAllComments, getGithub, - getLabels, } = require('./common'); async function doIt() { @@ -27,12 +28,13 @@ async function doIt() { if ( nowTs < targetTs ) { console.log(` will merged after ${dateStr}`); const label = `* ${dateStr} *`; - const labels = getLabels(''); - if ( ! labels.filter( (f) => { return f.name===`${label}`})) { - console.log(` will create label $label}`); - addLabel(`${label}, ``remind after ${dateStr}`, `#ffffff`); - } - addLabels(`${issue.number}`, `${label}`); + const labels = await getLabels(''); + //if ( ! labels.filter( (f) => { console.log( f.name ); return f.name===`${label}`})) { + if ( ! labels.includes(`${label}`)) { + console.log(` will create label $label}`); + await createLabel(`${label}`, `remind after ${dateStr}`, `#ffffff`); + } + await addLabel(`${issue.number}`, `${label}`); } else { console.log(` should be merged now (deadline ${dateStr})`); await addLabel(issue.number, ['⚠️check']); @@ -51,12 +53,13 @@ async function doIt() { if ( nowTs < targetTs ) { console.log(` will remind at ${dateStr}`); const label = `* ${dateStr} *`; - const labels = getLabels(''); - if ( ! labels.filter( (f) => { return f.name===`${label}`})) { - console.log(` will create label $label}`); - addLabel(`${label}, ``reminde after ${dateStr}`, `#ffffff`); + const labels = await getLabels(''); + //if ( ! labels.filter( (f) => { console.log( f.name ); return f.name===`${label}`})) { + if ( ! labels.includes(`${label}`)) { + console.log(` will create label ${label}`); + await createLabel(`${label}`, `remind after ${dateStr}`, `#ffffff`); } - addLabels(`${issue.number}`, `${label}`); + await addLabel(`${issue.number}`, `${label}`); } else { console.log(` should be checked now (deadline ${dateStr})`); await addLabel(issue.number, ['⚠️check']); @@ -76,12 +79,12 @@ async function doIt() { // activate for debugging purposes // process.env.GITHUB_REF = 'refs/pull/2348/merge'; -// process.env.OWN_GITHUB_TOKEN = 'insert token'; +// process.env.OWN_GITHUB_TOKEN = 'insert here'; // process.env.GITHUB_EVENT_PATH = __dirname + '/../event.json'; //console.log(`process.env.GITHUB_REF = ${process.env.GITHUB_REF}`); //console.log(`process.env.GITHUB_EVENT_PATH = ${process.env.GITHUB_EVENT_PATH}`); -//console.log(`process.env.OWN_GITHUB_TOKEN = ${(process.env.OWN_GITHUB_TOKEN || '').length}`); +console.log(`process.env.OWN_GITHUB_TOKEN = ${(process.env.OWN_GITHUB_TOKEN || '').length}`); doIt() .then(result => console.log(result))