Skip to content

Commit

Permalink
Github - Filter pull request review events by state (#14079)
Browse files Browse the repository at this point in the history
* filter pull_request_review events by state

* versions
  • Loading branch information
michelle0927 authored Sep 27, 2024
1 parent ca95fa1 commit 5efbd06
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion components/github/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/github",
"version": "1.4.0",
"version": "1.4.1",
"description": "Pipedream Github Components",
"main": "github.app.mjs",
"keywords": [
Expand Down
5 changes: 5 additions & 0 deletions components/github/sources/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ export default {
value: "opened",
},
],
PULL_REQUEST_REVIEW_STATES: [
"approved",
"changes_requested",
"commented",
],
};

export const SAMPLE_GITHUB_HEADERS = {
Expand Down
2 changes: 1 addition & 1 deletion components/github/sources/new-branch/new-branch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-branch",
name: "New Branch Created",
description: "Emit new event when a branch is created.",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "github-new-card-in-column",
name: "New Card in Column (Classic Projects)",
description: "Emit new event when a (classic) project card is created or moved to a specific column. For Projects V2 use `New Issue with Status` trigger. [More information here](https://docs.github.com/en/issues/organizing-your-work-with-project-boards/tracking-work-with-project-boards/adding-issues-and-pull-requests-to-a-project-board)",
version: "1.0.4",
version: "1.0.5",
type: "source",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-collaborator",
name: "New Collaborator",
description: "Emit new event when a collaborator is added",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-commit-comment",
name: "New Commit Comment",
description: "Emit new event when a commit comment is created",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/github/sources/new-commit/new-commit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-commit",
name: "New Commit",
description: "Emit new event when commits are pushed to a branch",
version: "1.0.6",
version: "1.0.7",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-discussion",
name: "New Discussion",
description: "Emit new event when a discussion is created",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
methods: {
Expand Down
2 changes: 1 addition & 1 deletion components/github/sources/new-fork/new-fork.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-fork",
name: "New Fork",
description: "Emit new event when a repository is forked",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-issue-with-status",
name: "Project Item Status Changed",
description: "Emit new event when a project item is tagged with a specific status. Currently supports Organization Projects only. [More information here](https://docs.github.com/en/issues/planning-and-tracking-with-projects/managing-items-in-your-project/adding-items-to-your-project)",
version: "0.1.2",
version: "0.1.3",
type: "source",
dedupe: "unique",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/github/sources/new-label/new-label.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-label",
name: "New Label",
description: "Emit new event when a new label is created",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
key: "github-new-or-updated-issue",
name: "New or Updated Issue",
description: "Emit new events when an issue is created or updated",
version: "1.1.2",
version: "1.1.3",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
key: "github-new-or-updated-milestone",
name: "New or Updated Milestone",
description: "Emit new event when a milestone is created or updated",
version: "1.1.2",
version: "1.1.3",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
key: "github-new-or-updated-pull-request",
name: "New or Updated Pull Request",
description: "Emit new event when a pull request is opened or updated",
version: "1.2.2",
version: "1.2.3",
type: "source",
dedupe: "unique",
methods: {
Expand Down
2 changes: 1 addition & 1 deletion components/github/sources/new-release/new-release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-release",
name: "New release",
description: "Emit new event when a new release is created",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
methods: {
Expand Down
2 changes: 1 addition & 1 deletion components/github/sources/new-star/new-star.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "github-new-star",
name: "New Stars",
description: "Emit new event when a repository is starred",
version: "1.0.5",
version: "1.0.6",
type: "source",
dedupe: "unique",
methods: {
Expand Down
23 changes: 21 additions & 2 deletions components/github/sources/webhook-events/webhook-events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default {
name: "New Webhook Event (Instant)",
description: "Emit new event for each selected event type",
type: "source",
version: "1.0.5",
version: "1.0.6",
dedupe: "unique",
props: {
docsInfo: {
type: "alert",
Expand All @@ -21,9 +22,23 @@ export default {
description: "The event types to be emitted",
type: "string[]",
options: constants.REPOSITORY_WEBHOOK_EVENTS,
reloadProps: true,
},
},
dedupe: "unique",
async additionalProps() {
await this.requireAdminPermission();
const props = {};
if (this.events?.length && this.events.includes("pull_request_review")) {
props.reviewState = {
type: "string",
label: "Review State",
description: "Filter `pull_request_review` events by review state",
options: constants.PULL_REQUEST_REVIEW_STATES,
optional: true,
};
}
return props;
},
methods: {
...common.methods,
getWebhookEvents() {
Expand All @@ -42,6 +57,10 @@ export default {
return;
}

if (headers["x-github-event"] === "pull_request_review" && this.reviewState && body.review.state !== this.reviewState) {
return;
}

this.$emit({
...getRelevantHeaders(headers),
...body,
Expand Down

0 comments on commit 5efbd06

Please sign in to comment.