Skip to content

Commit

Permalink
feat: support no_proxy environment variable (#1205)
Browse files Browse the repository at this point in the history
Co-authored-by: TGANSTE <till.ganster@mercedes-benz.com>
  • Loading branch information
tillganster and TGANSTE authored Aug 17, 2022
1 parent 10db758 commit 8557470
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/octokit-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ export const Octokit = Core.plugin(
autoProxyAgent
)

// Octokit plugin to support the https_proxy environment variable
// Octokit plugin to support the https_proxy and no_proxy environment variable
function autoProxyAgent(octokit: Core) {
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY

const noProxy = process.env.no_proxy || process.env.NO_PROXY
let noProxyArray: string[] = []
if (noProxy) {
noProxyArray = noProxy.split(',')
}

if (!proxy) return

const agent = new HttpsProxyAgent(proxy)
octokit.hook.before('request', options => {
if (noProxyArray.includes(options.request.hostname)) {
return
}
options.request.agent = agent
})
}

0 comments on commit 8557470

Please sign in to comment.