Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support no_proxy environment variable #1205

Merged
merged 1 commit into from Aug 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/octokit-client.ts
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
})
}