mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-10 01:08:07 +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) {
|
||||
fetch(`https://api.github.com/repos/xHyroM/bun-discord-bot/pulls/${pullRequestNumber}/reviews`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/vnd.github+json',
|
||||
'Authorization': `token ${githubToken}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
requestGithub(
|
||||
`pulls/${pullRequestNumber}/reviews`,
|
||||
{
|
||||
commit_id: commitSha,
|
||||
event: 'APPROVE',
|
||||
})
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
requestGithub(
|
||||
`issues/${pullRequestNumber}/labels/waiting`,
|
||||
{},
|
||||
'DELETE'
|
||||
);
|
||||
|
||||
requestGithub(
|
||||
`issues/${pullRequestNumber}/labels`,
|
||||
{
|
||||
labels: ['ready']
|
||||
}
|
||||
);
|
||||
} else {
|
||||
fetch(`https://api.github.com/repos/xHyroM/bun-discord-bot/pulls/${pullRequestNumber}/reviews`, {
|
||||
method: 'POST',
|
||||
requestGithub(
|
||||
`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: {
|
||||
'Accept': 'application/vnd.github+json',
|
||||
'Authorization': `token ${githubToken}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
commit_id: commitSha,
|
||||
body: 'Please fix the following problems:\n' + errors.join('\n'),
|
||||
event: 'REQUEST_CHANGES',
|
||||
})
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue