Skip to content

Commit

Permalink
added support of pull_request_review and pull_request_comment triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
whitershade committed Oct 5, 2021
1 parent 7431793 commit b510a32
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
10 changes: 9 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/constants/triggers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const allowed = [
"pull_request",
"pull_request_review",
"pull_request_review_comment",
];
4 changes: 4 additions & 0 deletions src/utils/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ describe("validateTrigger", () => {

test("should not throw an error if wrong eventType was provided", () => {
expect(() => utils.validateTrigger("pull_request")).not.toThrow();
expect(() => utils.validateTrigger("pull_request_review")).not.toThrow();
expect(() =>
utils.validateTrigger("pull_request_review_comment")
).not.toThrow();
});
});

Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AxiosError } from "axios";
import { getInput } from "@actions/core";
import * as ERRORS from "../constants/errors";
import * as TRIGGERS from "../constants/triggers";

export const getProjectsFromInput = (inputName: string): String[] => {
const projects = getInput(inputName);
Expand All @@ -10,7 +11,8 @@ export const getProjectsFromInput = (inputName: string): String[] => {
};

export const validateTrigger = (eventName: string) => {
if (eventName !== "pull_request") throw new Error(ERRORS.WRONG_TRIGGER);
if (!TRIGGERS.allowed.includes(eventName))
throw new Error(ERRORS.WRONG_TRIGGER);
};

export const validateProjectLists = (
Expand Down

0 comments on commit b510a32

Please sign in to comment.