mirror of
https://code.forgejo.org/actions/checkout.git
synced 2024-11-25 08:01:02 -05:00
make octokit follow proxy setting.
This commit is contained in:
parent
db41740e12
commit
5acb8ff4c9
4 changed files with 1724 additions and 6 deletions
1671
dist/index.js
vendored
1671
dist/index.js
vendored
File diff suppressed because one or more lines are too long
20
package-lock.json
generated
20
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -929,6 +929,11 @@
|
||||||
"integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==",
|
"integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"agent-base": {
|
||||||
|
"version": "5.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz",
|
||||||
|
"integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g=="
|
||||||
|
},
|
||||||
"ajv": {
|
"ajv": {
|
||||||
"version": "6.10.2",
|
"version": "6.10.2",
|
||||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
|
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
|
||||||
|
@ -1707,7 +1712,6 @@
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ms": "^2.1.1"
|
"ms": "^2.1.1"
|
||||||
}
|
}
|
||||||
|
@ -3670,6 +3674,15 @@
|
||||||
"sshpk": "^1.7.0"
|
"sshpk": "^1.7.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"https-proxy-agent": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==",
|
||||||
|
"requires": {
|
||||||
|
"agent-base": "5",
|
||||||
|
"debug": "4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"iconv-lite": {
|
"iconv-lite": {
|
||||||
"version": "0.4.24",
|
"version": "0.4.24",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||||
|
@ -4985,8 +4998,7 @@
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"mute-stream": {
|
"mute-stream": {
|
||||||
"version": "0.0.7",
|
"version": "0.0.7",
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
"@actions/github": "^2.0.0",
|
"@actions/github": "^2.0.0",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
"@actions/tool-cache": "^1.1.2",
|
"@actions/tool-cache": "^1.1.2",
|
||||||
|
"https-proxy-agent": "^4.0.0",
|
||||||
"uuid": "^3.3.3"
|
"uuid": "^3.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import * as retryHelper from './retry-helper'
|
||||||
import * as toolCache from '@actions/tool-cache'
|
import * as toolCache from '@actions/tool-cache'
|
||||||
import {default as uuid} from 'uuid/v4'
|
import {default as uuid} from 'uuid/v4'
|
||||||
import {ReposGetArchiveLinkParams} from '@octokit/rest'
|
import {ReposGetArchiveLinkParams} from '@octokit/rest'
|
||||||
|
import HttpsProxyAgent from 'https-proxy-agent'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ async function downloadArchive(
|
||||||
ref: string,
|
ref: string,
|
||||||
commit: string
|
commit: string
|
||||||
): Promise<Buffer> {
|
): Promise<Buffer> {
|
||||||
const octokit = new github.GitHub(authToken)
|
const octokit = createOctokit(authToken)
|
||||||
const params: ReposGetArchiveLinkParams = {
|
const params: ReposGetArchiveLinkParams = {
|
||||||
owner: owner,
|
owner: owner,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
|
@ -90,3 +91,38 @@ async function downloadArchive(
|
||||||
|
|
||||||
return Buffer.from(response.data) // response.data is ArrayBuffer
|
return Buffer.from(response.data) // response.data is ArrayBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createOctokit(authToken: string): github.GitHub {
|
||||||
|
let proxyVar: string =
|
||||||
|
process.env['https_proxy'] || process.env['HTTPS_PROXY'] || ''
|
||||||
|
|
||||||
|
if (!proxyVar) {
|
||||||
|
return new github.GitHub(authToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
let noProxy: string = process.env['no_proxy'] || process.env['NO_PROXY'] || ''
|
||||||
|
|
||||||
|
let bypass: boolean = false
|
||||||
|
if (noProxy) {
|
||||||
|
let bypassList = noProxy.split(',')
|
||||||
|
for (let i = 0; i < bypassList.length; i++) {
|
||||||
|
let item = bypassList[i]
|
||||||
|
if (
|
||||||
|
item &&
|
||||||
|
typeof item === 'string' &&
|
||||||
|
item.trim().toLocaleLowerCase() === 'github.com'
|
||||||
|
) {
|
||||||
|
bypass = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bypass) {
|
||||||
|
return new github.GitHub(authToken)
|
||||||
|
} else {
|
||||||
|
return new github.GitHub(authToken, {
|
||||||
|
request: {agent: new HttpsProxyAgent(proxyVar)}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue