feat: support no_proxy environment variable (#1205)
Co-authored-by: TGANSTE <till.ganster@mercedes-benz.com>
This commit is contained in:
parent
10db75894f
commit
8557470a68
1 changed files with 11 additions and 1 deletions
|
@ -11,13 +11,23 @@ export const Octokit = Core.plugin(
|
||||||
autoProxyAgent
|
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) {
|
function autoProxyAgent(octokit: Core) {
|
||||||
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY
|
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
|
if (!proxy) return
|
||||||
|
|
||||||
const agent = new HttpsProxyAgent(proxy)
|
const agent = new HttpsProxyAgent(proxy)
|
||||||
octokit.hook.before('request', options => {
|
octokit.hook.before('request', options => {
|
||||||
|
if (noProxyArray.includes(options.request.hostname)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
options.request.agent = agent
|
options.request.agent = agent
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue