diff --git a/lib/datasource/github.js b/lib/datasource/github.js index edef25e76daa073a803da63653811d8aac827277..518612cd7418311c02710f8db5b01c1d9961ddb0 100644 --- a/lib/datasource/github.js +++ b/lib/datasource/github.js @@ -9,6 +9,16 @@ async function getDependency(repo, options = {}) { const ref = options.ref || 'tag'; const clean = options.clean === 'true'; let versions; + let endpoint; + let token; + // istanbul ignore if + if (process.env.GITHUB_ENDPOINT) { + logger.debug('Removing GHE token before retrieving node releases'); + endpoint = process.env.GITHUB_ENDPOINT; + delete process.env.GITHUB_ENDPOINT; + token = process.env.GITHUB_TOKEN; + process.env.GITHUB_TOKEN = process.env.GITHUB_COM_TOKEN; + } try { if (ref === 'tag') { const url = `repos/${repo}/git/refs/tags?per_page=100`; @@ -27,6 +37,13 @@ async function getDependency(repo, options = {}) { { repo, err, message: err.message }, 'Error retrieving from github' ); + } finally { + // istanbul ignore if + if (endpoint) { + logger.debug('Restoring GHE token and endpoint'); + process.env.GITHUB_TOKEN = token; + process.env.GITHUB_ENDPOINT = endpoint; + } } if (!versions) { return null;