From 0f7c123bc8bd33636dafbc88f4642974c8729cad Mon Sep 17 00:00:00 2001 From: Michael Shick Date: Mon, 25 Nov 2019 18:15:31 -0500 Subject: [PATCH] handle non-pr payloads --- index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d346af2..fe1f760 100644 --- a/index.js +++ b/index.js @@ -11,12 +11,17 @@ async function run() { core.debug(`input allow-repeats: ${allowRepeats}`); const { - payload: { - pull_request: { number: issueNumber }, - repository: { full_name: repoFullName } - } + payload: { pull_request: pullRequest, repository } } = github.context; + if (!pullRequest) { + core.error("this action only works on pull_request events"); + core.setOutput("comment-created", "false"); + return; + } + + const { number: issueNumber } = pullRequest; + const { full_name: repoFullName } = repository; const [owner, repo] = repoFullName.split("/"); const octokit = new github.GitHub(repoToken);