Skip to content

Commit

Permalink
feat: switch proxy implementation (#1269)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans authored Oct 18, 2022
1 parent ad43dcc commit b4d5173
Show file tree
Hide file tree
Showing 8 changed files with 58,450 additions and 4,874 deletions.
1,010 changes: 1,010 additions & 0 deletions dist/bridge.js

Large diffs are not rendered by default.

977 changes: 977 additions & 0 deletions dist/events.js

Large diffs are not rendered by default.

59,457 changes: 54,640 additions & 4,817 deletions dist/index.js

Large diffs are not rendered by default.

469 changes: 469 additions & 0 deletions dist/setup-node-sandbox.js

Large diffs are not rendered by default.

457 changes: 457 additions & 0 deletions dist/setup-sandbox.js

Large diffs are not rendered by default.

931 changes: 888 additions & 43 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@octokit/core": "^3.5.1",
"@octokit/plugin-paginate-rest": "^2.17.0",
"@octokit/plugin-rest-endpoint-methods": "^5.13.0",
"https-proxy-agent": "^5.0.0",
"proxy-agent": "^5.0.0",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down
21 changes: 8 additions & 13 deletions src/octokit-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Octokit as Core} from '@octokit/core'
import {paginateRest} from '@octokit/plugin-paginate-rest'
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
import {HttpsProxyAgent} from 'https-proxy-agent'
import ProxyAgent from 'proxy-agent'
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
export {OctokitOptions} from '@octokit/core/dist-types/types'

Expand All @@ -11,23 +11,18 @@ export const Octokit = Core.plugin(
autoProxyAgent
)

// Octokit plugin to support the https_proxy and no_proxy environment variable
// Octokit plugin to support the standard environment variables http_proxy, https_proxy and no_proxy
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(',')
}
const proxy =
process.env.https_proxy ||
process.env.HTTPS_PROXY ||
process.env.http_proxy ||
process.env.HTTP_PROXY

if (!proxy) return

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

0 comments on commit b4d5173

Please sign in to comment.