Skip to content

Commit 68800ec

Browse files
committed
new component new-issue-comment
1 parent 337cca4 commit 68800ec

File tree

3 files changed

+150
-1
lines changed

3 files changed

+150
-1
lines changed

components/github/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/github",
3-
"version": "1.6.2",
3+
"version": "1.7.0",
44
"description": "Pipedream Github Components",
55
"main": "github.app.mjs",
66
"keywords": [
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { SAMPLE_GITHUB_HEADERS } from "../common/constants.mjs";
2+
3+
export function getSampleWebhookEvent() {
4+
return {
5+
...SAMPLE_GITHUB_HEADERS,
6+
"url": "https://api.github.com/repos/user/repo/issues/comments/2675481838",
7+
"html_url": "https://github.com/user/repo/issues/8#issuecomment-2675481838",
8+
"issue_url": "https://api.github.com/repos/user/repo/issues/8",
9+
"id": 2675481838,
10+
"node_id": "IC_kwDOAmjbCM6feJzu",
11+
"user": {
12+
"login": "user",
13+
"id": 10889229,
14+
"node_id": "MDQ6VXNlcjEwODg5MjI5",
15+
"avatar_url": "https://avatars.githubusercontent.com/u/10889229?v=4",
16+
"gravatar_id": "",
17+
"url": "https://api.github.com/users/user",
18+
"html_url": "https://github.com/user",
19+
"followers_url": "https://api.github.com/users/user/followers",
20+
"following_url": "https://api.github.com/users/user/following{/other_user}",
21+
"gists_url": "https://api.github.com/users/user/gists{/gist_id}",
22+
"starred_url": "https://api.github.com/users/user/starred{/owner}{/repo}",
23+
"subscriptions_url": "https://api.github.com/users/user/subscriptions",
24+
"organizations_url": "https://api.github.com/users/user/orgs",
25+
"repos_url": "https://api.github.com/users/user/repos",
26+
"events_url": "https://api.github.com/users/user/events{/privacy}",
27+
"received_events_url": "https://api.github.com/users/user/received_events",
28+
"type": "User",
29+
"user_view_type": "public",
30+
"site_admin": false,
31+
},
32+
"created_at": "2025-02-21T20:29:49Z",
33+
"updated_at": "2025-02-21T20:29:49Z",
34+
"author_association": "OWNER",
35+
"body": "hello world",
36+
"reactions": {
37+
"url": "https://api.github.com/repos/user/repo/issues/comments/2675481838/reactions",
38+
"total_count": 0,
39+
"+1": 0,
40+
"-1": 0,
41+
"laugh": 0,
42+
"hooray": 0,
43+
"confused": 0,
44+
"heart": 0,
45+
"rocket": 0,
46+
"eyes": 0,
47+
},
48+
"performed_via_github_app": null,
49+
"github_headers": {
50+
"x-github-delivery": "99a89b30-f092-11ef-80fb-37d0e2023dc5",
51+
"x-github-event": "issue_comment",
52+
"x-github-hook-id": "531386725",
53+
},
54+
};
55+
}
56+
57+
export function getSampleTimerEvent() {
58+
return {
59+
"url": "https://api.github.com/repos/user/repo/issues/comments/2675511709",
60+
"html_url": "https://github.com/user/repo/issues/8#issuecomment-2675511709",
61+
"issue_url": "https://api.github.com/repos/user/repo/issues/8",
62+
"id": 2675511709,
63+
"node_id": "IC_kwDOAmjbCM6feRGd",
64+
"user": {
65+
"login": "user",
66+
"id": 10889229,
67+
"node_id": "MDQ6VXNlcjEwODg5MjI5",
68+
"avatar_url": "https://avatars.githubusercontent.com/u/10889229?v=4",
69+
"gravatar_id": "",
70+
"url": "https://api.github.com/users/user",
71+
"html_url": "https://github.com/user",
72+
"followers_url": "https://api.github.com/users/user/followers",
73+
"following_url": "https://api.github.com/users/user/following{/other_user}",
74+
"gists_url": "https://api.github.com/users/user/gists{/gist_id}",
75+
"starred_url": "https://api.github.com/users/user/starred{/owner}{/repo}",
76+
"subscriptions_url": "https://api.github.com/users/user/subscriptions",
77+
"organizations_url": "https://api.github.com/users/user/orgs",
78+
"repos_url": "https://api.github.com/users/user/repos",
79+
"events_url": "https://api.github.com/users/user/events{/privacy}",
80+
"received_events_url": "https://api.github.com/users/user/received_events",
81+
"type": "User",
82+
"user_view_type": "public",
83+
"site_admin": false,
84+
},
85+
"created_at": "2025-02-21T20:48:06Z",
86+
"updated_at": "2025-02-21T20:48:06Z",
87+
"author_association": "OWNER",
88+
"body": "hello world",
89+
"reactions": {
90+
"url": "https://api.github.com/repos/user/repo/issues/comments/2675511709/reactions",
91+
"total_count": 0,
92+
"+1": 0,
93+
"-1": 0,
94+
"laugh": 0,
95+
"hooray": 0,
96+
"confused": 0,
97+
"heart": 0,
98+
"rocket": 0,
99+
"eyes": 0,
100+
},
101+
"performed_via_github_app": null,
102+
};
103+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import common from "../common/common-flex.mjs";
2+
import {
3+
getSampleTimerEvent, getSampleWebhookEvent,
4+
} from "./common-sample-events.mjs";
5+
6+
export default {
7+
...common,
8+
key: "github-new-issue-comment",
9+
name: "New Issue Comment",
10+
description: "Emit new event when a new comment is added to an issue or pull request",
11+
version: "0.0.1",
12+
type: "source",
13+
dedupe: "unique",
14+
methods: {
15+
...common.methods,
16+
getSampleWebhookEvent,
17+
getSampleTimerEvent,
18+
getWebhookEvents() {
19+
return [
20+
"issue_comment",
21+
];
22+
},
23+
shouldEmitWebhookEvent(body) {
24+
return body?.action === "created";
25+
},
26+
getWebhookEventItem(body) {
27+
return body.comment;
28+
},
29+
getSummary(item) {
30+
return `New comment: ${this.getId(item)}`;
31+
},
32+
async getPollingData({ repoFullname }) {
33+
const { data } = await this.github._client().request(`GET /repos/${repoFullname}/issues/comments`, {
34+
sort: "created",
35+
direction: "desc",
36+
});
37+
return data;
38+
},
39+
getHttpDocsLink() {
40+
return "https://docs.github.com/en/webhooks/webhook-events-and-payloads#issue_comment";
41+
},
42+
getTimerDocsLink() {
43+
return "https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#list-issue-comments-for-a-repository";
44+
},
45+
},
46+
};

0 commit comments

Comments
 (0)