From 7cd65d7cb4588571cca95e34668e067a1505c130 Mon Sep 17 00:00:00 2001 From: Martin M Date: Mon, 25 Dec 2023 13:44:55 +0100 Subject: [PATCH 1/3] extend label support --- lib/common.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/common.js b/lib/common.js index edbafd9af..dfc321370 100644 --- a/lib/common.js +++ b/lib/common.js @@ -15,7 +15,11 @@ function addLabel(prID, labels) { } function deleteLabel(prID, label) { - return axios.delete(`https://api.github.com/repos/ioBroker/ioBroker.repositories/issues/${prID}/labels/${label}`, { + let url = `labels/${label}`; + if (prID) { + ulr= `issues/${prID}/labels/${label}` + } + return axios.delete(`https://api.github.com/repos/ioBroker/ioBroker.repositories/${url}`, { headers: { Authorization: process.env.OWN_GITHUB_TOKEN ? `token ${process.env.OWN_GITHUB_TOKEN}` : 'none', 'user-agent': 'Action script' @@ -25,7 +29,11 @@ function deleteLabel(prID, label) { } function getLabels(prID) { - return axios(`https://api.github.com/repos/ioBroker/ioBroker.repositories/issues/${prID}/labels`, + let url = `labels`; + if (prID) { + ulr= `issues/${prID}/labels` + } + return axios(`https://api.github.com/repos/ioBroker/ioBroker.repositories/${url}`, { headers: { Authorization: process.env.OWN_GITHUB_TOKEN ? `token ${process.env.OWN_GITHUB_TOKEN}` : 'none', @@ -35,6 +43,22 @@ function getLabels(prID) { .then(response => response.data ) } +function createLabel(label, name, description, color) { + return axios.post(`https://api.github.com/repos/ioBroker/ioBroker.repositories/labels`, + { + "name": name, + "description": description, + "color": color + }, + { + headers: { + Authorization: process.env.OWN_GITHUB_TOKEN ? `token ${process.env.OWN_GITHUB_TOKEN}` : 'none', + 'user-agent': 'Action script' + } + }) + .then(response => response.data); +} + function addComment(prID, body) { return axios.post(`https://api.github.com/repos/ioBroker/ioBroker.repositories/issues/${prID}/comments`, {body}, { @@ -122,11 +146,12 @@ function getUrl(url, asText) { module.exports = { addComment, addLabel, + createLabel, + deleteLabel, getGithub, getUrl, createIssue, deleteComment, - deleteLabel, getAllComments, getLabels }; From af7e19f27d567ac7907db059923e3bc0571f1f5e Mon Sep 17 00:00:00 2001 From: Martin M Date: Mon, 25 Dec 2023 13:45:08 +0100 Subject: [PATCH 2/3] create and set labels --- lib/stableBrandNewReminder.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/stableBrandNewReminder.js b/lib/stableBrandNewReminder.js index cb317dea0..89a6fd901 100644 --- a/lib/stableBrandNewReminder.js +++ b/lib/stableBrandNewReminder.js @@ -3,6 +3,7 @@ const { addLabel, getAllComments, getGithub, + getLabels, } = require('./common'); async function doIt() { @@ -25,6 +26,12 @@ async function doIt() { const nowTs = new Date().getTime(); if ( nowTs < targetTs ) { console.log(` will merged after ${dateStr}`); + const label = `* ${dateStr} *`; + const labels = getLabels(''); + if ( ! labels.includes(`${label}`)) { + addLabel(`${label}, ``reminde after ${dateStr}`, `000000`); + addLabels(`${issue.number}`, `${label}`); + } } else { console.log(` should be merged now (deadline ${dateStr})`); await addLabel(issue.number, ['⚠️check']); From bb17676b428c737184ec79f9e2b75effa349ef8b Mon Sep 17 00:00:00 2001 From: Martin M Date: Mon, 25 Dec 2023 13:45:30 +0100 Subject: [PATCH 3/3] Update stableBrandNewReminder.js --- lib/stableBrandNewReminder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stableBrandNewReminder.js b/lib/stableBrandNewReminder.js index 89a6fd901..51f9082ef 100644 --- a/lib/stableBrandNewReminder.js +++ b/lib/stableBrandNewReminder.js @@ -30,8 +30,8 @@ async function doIt() { const labels = getLabels(''); if ( ! labels.includes(`${label}`)) { addLabel(`${label}, ``reminde after ${dateStr}`, `000000`); - addLabels(`${issue.number}`, `${label}`); } + addLabels(`${issue.number}`, `${label}`); } else { console.log(` should be merged now (deadline ${dateStr})`); await addLabel(issue.number, ['⚠️check']);