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 }; diff --git a/lib/stableBrandNewReminder.js b/lib/stableBrandNewReminder.js index cb317dea0..51f9082ef 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']);