Skip to content

Commit

Permalink
Uses octokit to grab the PR metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed May 20, 2018
1 parent 0272a67 commit 45293d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ const checkREADME = async () => {
}
checkREADME()

import yarn, { message } from "danger-plugin-yarn"
import yarn from "danger-plugin-yarn"
yarn()

import jest from "danger-plugin-jest"
jest()

warn("I should be in the checks")

// Re-run the git push hooks
import "./dangerfile.lite"
15 changes: 12 additions & 3 deletions source/platforms/github/comms/checksCommenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ export const GitHubChecksCommenter = (api: GitHubAPI): PlatformCommunicator | un
handlePostingResults: async (results: DangerResults, options: ExecutorOptions) => {
d("Getting PR details for checks")

const pr = await api.getPullRequestInfo()

let octokit
if (options.accessTokenIsGitHubApp) {
d("Using the default GH API for Checks")
Expand All @@ -88,7 +86,18 @@ export const GitHubChecksCommenter = (api: GitHubAPI): PlatformCommunicator | un
return
}

const checkData = await resultsToCheck(results, options, pr, octokit)
// Use octokit to grab the checks data
const owner = api.repoMetadata.repoSlug.split("/")[0]
const repo = api.repoMetadata.repoSlug.split("/")[1]
const prResponse = await octokit.pullRequests.get({
repo,
owner,
number: parseInt(api.repoMetadata.pullRequestID),
})

d("Got PR:", JSON.stringify(prResponse.data))

const checkData = await resultsToCheck(results, options, prResponse.data, octokit)
const response = await octokit.checks.create(checkData)
d("Got response on the check API")
d(JSON.stringify(response))
Expand Down

0 comments on commit 45293d2

Please sign in to comment.