mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 16:43:08 +02:00
[Server] Improve github notification
This commit is contained in:
parent
9e97ca4caa
commit
9228e8eab9
1 changed files with 43 additions and 5 deletions
|
@ -24,8 +24,12 @@ module.exports = async (app: express.Application) => {
|
||||||
|
|
||||||
app.post('/hooks/github', handler);
|
app.post('/hooks/github', handler);
|
||||||
|
|
||||||
handler.on('*', event => {
|
handler.on('push', event => {
|
||||||
console.dir(event);
|
const ref = event.payload.ref;
|
||||||
|
if (ref != 'refs/heads/master') return;
|
||||||
|
const pusher = event.payload.pusher;
|
||||||
|
const compare = event.payload.compare;
|
||||||
|
post(`Pushed! (Pusher: ${pusher.name})\nCompare changes: ${compare}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on('issues', event => {
|
handler.on('issues', event => {
|
||||||
|
@ -33,11 +37,45 @@ module.exports = async (app: express.Application) => {
|
||||||
const action = event.payload.action;
|
const action = event.payload.action;
|
||||||
let title: string;
|
let title: string;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'opened': title = 'Issueが立ちました'; break;
|
case 'opened': title = 'New Issue'; break;
|
||||||
case 'closed': title = 'Issueが閉じられました'; break;
|
case 'closed': title = 'Issue Closed'; break;
|
||||||
case 'reopened': title = 'Issueが開きました'; break;
|
case 'reopened': title = 'Issue Reopened'; break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
post(`${title}: ${issue.number}「${issue.title}」\n${issue.html_url}`);
|
post(`${title}: ${issue.number}「${issue.title}」\n${issue.html_url}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
handler.on('issue_comment', event => {
|
||||||
|
const issue = event.payload.issue;
|
||||||
|
const comment = event.payload.comment;
|
||||||
|
const action = event.payload.action;
|
||||||
|
let text: string;
|
||||||
|
switch (action) {
|
||||||
|
case 'created': text = `Comment to「${issue.title}」:${comment.user.login}「${comment.body}」\n${comment.html_url}`; break;
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
post(text);
|
||||||
|
});
|
||||||
|
|
||||||
|
handler.on('fork', event => {
|
||||||
|
const repo = event.payload.forkee;
|
||||||
|
post(`Forked:\n${repo.html_url}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
handler.on('pull_request', event => {
|
||||||
|
const pr = event.payload.pull_request;
|
||||||
|
const action = event.payload.action;
|
||||||
|
let text: string;
|
||||||
|
switch (action) {
|
||||||
|
case 'opened': text = `New Pull Request:「${pr.title}」\n${pr.html_url}`; break;
|
||||||
|
case 'reopened': text = `Pull Request Reopened:「${pr.title}」\n${pr.html_url}`; break;
|
||||||
|
case 'closed':
|
||||||
|
text = pr.merged
|
||||||
|
? `Pull Request Merged!:「${pr.title}」\n${pr.html_url}`
|
||||||
|
: `Pull Request Closed:「${pr.title}」\n${pr.html_url}`;
|
||||||
|
break;
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
post(text);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue