forked from ubiquity/ubiquibot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallbackOnAny.ts
More file actions
62 lines (55 loc) · 1.64 KB
/
Copy pathcallbackOnAny.ts
File metadata and controls
62 lines (55 loc) · 1.64 KB
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
56
57
58
59
60
61
62
import { Context } from "probot";
import { Payload } from "../interfaces/Payload";
import { pricingLabelLogic } from "./pricing-label-logic";
export async function callbackOnAny(context: Context) {
const payload = context.payload as Payload;
const ACTION = payload.action;
console.log(ACTION);
if (payload.sender.type == "Bot") return; // ignore bot invoked events
if (context.name != "issues" && context.name != "issue_comment") return; // ignore non-issue related events
switch (ACTION) {
// comments
case "deleted":
case "edited":
case "created":
// // @ts-ignore-error
// const body = payload.comment.body as string;
// console.log(body);
// if (body.includes("timeline")) {
// const timelineEvents = await listTimelineEventsForIssue(context);
// console.log(timelineEvents);
// }
// break;
// issue general
case "labeled":
case "unlabeled":
await pricingLabelLogic(payload, context);
break;
case "assigned":
case "unassigned":
case "opened":
case "edited":
case "closed":
case "reopened":
// case "milestoned":
// case "demilestoned":
// case "locked":
// case "unlocked":
// case "transferred":
// case "pinned":
// case "unpinned":
default:
break;
}
}
async function listTimelineEventsForIssue(context: Context) {
const payload = context.payload as Payload;
const { owner, repo } = context.repo();
const { data: timelineEvents } = await context.octokit.issues.listEventsForTimeline({
owner,
repo,
issue_number: payload.issue.number,
per_page: 10,
});
return timelineEvents;
}