From cefab2c1e43f8c89f2bc50ee7e12fdd2a901eb48 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Sat, 8 Feb 2020 10:48:09 -0600 Subject: [PATCH] fix to handle comment creation events --- index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 2b2206d..a1e4bc6 100644 --- a/index.js +++ b/index.js @@ -15,11 +15,14 @@ async function run() { const octokit = new github.GitHub(token); const payload = github.context.payload; - const issuesArgs = { - owner: (payload.organization || payload.repository.owner).login, - repo: payload.repository.name, - issue_number: payload.pull_request.number - }; + // personal repos have no org + const owner = (payload.organization || payload.repository.owner).login; + const repo = payload.repository.name; + + // issue events (like create comment) supply #issue instead od #pull_request + const issue_number = (payload.pull_request || payload.issue).number; + + const issuesArgs = { owner, repo, issue_number }; const pull = await octokit.issues.get(issuesArgs); console.log(`pr body: ${pull.data.body}`);