Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reminder label support #3115

Merged
merged 3 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}

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'
Expand All @@ -25,7 +29,11 @@
}

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',
Expand All @@ -35,6 +43,22 @@
.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',

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

The hard-coded value "none" is used as
authorization header
.
'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},
{
Expand Down Expand Up @@ -122,11 +146,12 @@
module.exports = {
addComment,
addLabel,
createLabel,
deleteLabel,
getGithub,
getUrl,
createIssue,
deleteComment,
deleteLabel,
getAllComments,
getLabels
};
7 changes: 7 additions & 0 deletions lib/stableBrandNewReminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
addLabel,
getAllComments,
getGithub,
getLabels,
} = require('./common');

async function doIt() {
Expand All @@ -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']);
Expand Down
Loading