diff --git a/configs/.env b/configs/.env index 006c523df..7e79e5f30 100644 --- a/configs/.env +++ b/configs/.env @@ -24,8 +24,10 @@ GITHUB_DEPLOY_KEY_BITS=2048 GITHUB_DEPLOY_KEYS_POOL_SIZE=10 GITHUB_HOOK_NAME=web GITHUB_HOOK_SECRET=3V3RYTHINGisAW3S0ME! +GITHUB_HOST=github.com GITHUB_PROXY_EXPIRATION=3600 GITHUB_SCOPE=user:email,read:org,repo,repo_deployment,read:repo_hook,repo:status +GITHUB_URL=https://github.com HASHIDS_LENGTH=6 HASHIDS_SALT=VvCCYj8x3xaHs44QiDp9 HELLO_RUNNABLE_GITHUB_ID=10224339 diff --git a/lib/models/apis/docker.js b/lib/models/apis/docker.js index 24c14424b..eaf054ce4 100644 --- a/lib/models/apis/docker.js +++ b/lib/models/apis/docker.js @@ -393,7 +393,7 @@ Docker.prototype._createImageBuilderEnv = function (opts) { const commitishs = [] const deployKeys = [] contextVersion.appCodeVersions.forEach(function (acv) { - repoUrls.push('git@github.com:' + acv.repo) + repoUrls.push(`git@${process.env.GITHUB_HOST}:${acv.repo}`) // use either a commit, branch, or default to master commitishs.push(acv.commit || acv.branch || 'master') if (acv.privateKey) { diff --git a/lib/routes/actions/redirect.js b/lib/routes/actions/redirect.js index e366bb2ca..e04557517 100644 --- a/lib/routes/actions/redirect.js +++ b/lib/routes/actions/redirect.js @@ -18,7 +18,7 @@ app.get('/actions/redirect', return res.status(404).end() } var url = decodeURIComponent(req.query.url) - if (url.indexOf('https://github.com/') !== 0) { + if (url.indexOf(process.env.GITHUB_URL) !== 0) { return res.status(404).end() } res.redirect(302, url) diff --git a/lib/routes/contexts/versions/app-code-versions.js b/lib/routes/contexts/versions/app-code-versions.js index f57747931..699310520 100644 --- a/lib/routes/contexts/versions/app-code-versions.js +++ b/lib/routes/contexts/versions/app-code-versions.js @@ -181,7 +181,7 @@ app.post('/contexts/:contextId/versions/:versionId/appCodeVersions/:appCodeVersi optimus.transform( { // optimus does not assume that it is coming from github should it? - repo: 'git@github.com:' + appCodeVersion.repo, + repo: `git@${process.env.GITHUB_HOST}:${appCodeVersion.repo}`, commitish: appCodeVersion.commit, rules: rules, deployKey: appCodeVersion.privateKey @@ -268,7 +268,7 @@ app.post('/contexts/:contextId/versions/:versionId/appCodeVersions/:appCodeVersi // Ask optimus for the results... optimus.transform( { - repo: 'git@github.com:' + appCodeVersion.repo, + repo: `git@${process.env.GITHUB_HOST}:${appCodeVersion.repo}`, commitish: appCodeVersion.commit, rules: rules, deployKey: appCodeVersion.privateKey diff --git a/lib/routes/github/index.js b/lib/routes/github/index.js index cf96d63d7..3e3efb17f 100644 --- a/lib/routes/github/index.js +++ b/lib/routes/github/index.js @@ -41,10 +41,9 @@ var cacheOmitHeaders = [ ].concat(corsHeaders) var proxy = httpProxy.createProxy({ - target: 'https://api.github.com', + target: 'http://' + process.env.GITHUB_VARNISH_HOST + ':' + process.env.GITHUB_VARNISH_PORT, // github wants these headers headers: { - host: 'api.github.com', accept: 'application/vnd.github.v3+json' } })