diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 29f37f1947972f00483d28f49c43abb63db0ce79..91be8936dc704bfac4433ad69a1d68661a40ed4d 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 ); }