-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlePullRequestClosed.js
55 lines (52 loc) · 1.16 KB
/
handlePullRequestClosed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const { PullRequestClosed } = require('./models'); // Import your Sequelize PullRequestClosed model
async function handlePullRequestClosed(payload) {
const {
action,
pull_request: {
url: Url,
id,
user: { login: Author },
created_at,
updated_at,
merged_at,
closed_at,
head: { ref: head_branch },
base: { ref: base_branch },
comments,
review_comments,
commits,
additions,
deletions,
changed_files,
},
repository: { id: Repository },
sender: { login: sender },
} = payload;
try {
const newPullRequest = await PullRequestClosed.create({
id,
Url,
Author,
created_at,
updated_at,
merged_at,
closed_at,
head_branch,
base_branch,
comments,
review_comments,
Commits: commits,
additions,
deletions,
changed_files,
Repository,
sender,
action,
});
console.log('New pull request Closed:', newPullRequest.toJSON());
} catch (error) {
console.error('Error handling pull request Closed:', error);
throw error;
}
}
module.exports = handlePullRequestClosed;