Skip to content

Commit

Permalink
fix(minimize-comments): provide better error on non-pull-request even…
Browse files Browse the repository at this point in the history
…ts (#29)

If the action is used on an event that's not 'pull-request' there wont' be any comments to minimize, so provide a better error instead of a random failure out of graphql.

Future TODO: allow other event types (like maybe issue) that do have a way to look up comments
  • Loading branch information
mdobosz-isp authored Sep 1, 2020
1 parent a3d7c2f commit 067cb39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion minimize-comments/dist/index.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions minimize-comments/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ run();

async function run() {
try {
// Note: supporting other event types might require changing the query used
if (context.eventName !== "pull_request") {
throw new Error(
`This action is not supported for event of type '${context.eventName}'.`
);
}

const token = getInput("github-token", { required: true });
const bodyIncludesInput = getInput("body-includes", { required: true });
const bodyStrings = bodyIncludesInput
Expand Down

0 comments on commit 067cb39

Please sign in to comment.