Skip to content

Commit

Permalink
fix to handle comment creation events
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Henry committed Feb 8, 2020
1 parent 3072fb7 commit cefab2c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit cefab2c

Please sign in to comment.