From c58498a9a900806b2f401cf948f8e4789dbe5fbe Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 14 Dec 2017 12:11:30 +0100 Subject: [PATCH] fix: use forkToken when creating or updating PR --- lib/platform/github/index.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 29f37f1947..91be8936dc 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -581,16 +581,22 @@ async function createPr(branchName, title, body, labels, useDefaultBranch) { const base = useDefaultBranch ? config.defaultBranch : config.baseBranch; // Include the repository owner to handle forkMode and regular mode const head = `${config.repoName.split('/')[0]}:${branchName}`; + const options = { + body: { + title, + head, + base, + body, + }, + }; + // istanbul ignore if + if (config.forkToken) { + options.token = config.forkToken; + } + logger.debug({ title, head, base }, 'Creating PR'); const pr = (await get.post( `repos/${config.parentRepo || config.repoName}/pulls`, - { - body: { - title, - head, - base, - body, - }, - } + options )).body; pr.displayNumber = `Pull Request #${pr.number}`; await addLabels(pr.number, labels); @@ -685,11 +691,16 @@ async function updatePr(prNo, title, body) { if (body) { patchBody.body = body; } + const options = { + body: patchBody, + }; + // istanbul ignore if + if (config.forkToken) { + options.token = config.forkToken; + } await get.patch( `repos/${config.parentRepo || config.repoName}/pulls/${prNo}`, - { - body: patchBody, - } + options ); } -- GitLab