mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-22 14:41:05 +01:00
chore(validateTags): auto add labels
This commit is contained in:
parent
d5389a6757
commit
f59112306c
1 changed files with 39 additions and 16 deletions
|
@ -49,29 +49,52 @@ for (const [key, value] of Object.entries(tags)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors.length === 0) {
|
if (errors.length === 0) {
|
||||||
fetch(`https://api.github.com/repos/xHyroM/bun-discord-bot/pulls/${pullRequestNumber}/reviews`, {
|
requestGithub(
|
||||||
method: 'POST',
|
`pulls/${pullRequestNumber}/reviews`,
|
||||||
headers: {
|
{
|
||||||
'Accept': 'application/vnd.github+json',
|
|
||||||
'Authorization': `token ${githubToken}`
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
commit_id: commitSha,
|
commit_id: commitSha,
|
||||||
event: 'APPROVE',
|
event: 'APPROVE',
|
||||||
})
|
}
|
||||||
})
|
);
|
||||||
|
|
||||||
|
requestGithub(
|
||||||
|
`issues/${pullRequestNumber}/labels/waiting`,
|
||||||
|
{},
|
||||||
|
'DELETE'
|
||||||
|
);
|
||||||
|
|
||||||
|
requestGithub(
|
||||||
|
`issues/${pullRequestNumber}/labels`,
|
||||||
|
{
|
||||||
|
labels: ['ready']
|
||||||
|
}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
fetch(`https://api.github.com/repos/xHyroM/bun-discord-bot/pulls/${pullRequestNumber}/reviews`, {
|
requestGithub(
|
||||||
method: 'POST',
|
`pulls/${pullRequestNumber}/reviews`,
|
||||||
|
{
|
||||||
|
commit_id: commitSha,
|
||||||
|
body: '### Please fix the following problems:\n' + errors.join('\n'),
|
||||||
|
event: 'REQUEST_CHANGES',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
requestGithub(
|
||||||
|
`issues/${pullRequestNumber}/labels`,
|
||||||
|
{
|
||||||
|
labels: ['waiting']
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestGithub(url: string, body: any, method?: 'POST' | 'DELETE') {
|
||||||
|
fetch(`https://api.github.com/repos/xHyroM/bun-discord-bot/${url}`, {
|
||||||
|
method: method || 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/vnd.github+json',
|
'Accept': 'application/vnd.github+json',
|
||||||
'Authorization': `token ${githubToken}`
|
'Authorization': `token ${githubToken}`
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify(body)
|
||||||
commit_id: commitSha,
|
|
||||||
body: 'Please fix the following problems:\n' + errors.join('\n'),
|
|
||||||
event: 'REQUEST_CHANGES',
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue