Skip to content

Commit caca336

Browse files
committed
handle proxy settings for aws-sdk
Signed-off-by: CrazyMax <[email protected]>
1 parent 17f28ab commit caca336

File tree

8 files changed

+58064
-3350
lines changed

8 files changed

+58064
-3350
lines changed

dist/bridge.js

Lines changed: 984 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/events.js

Lines changed: 1033 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 54807 additions & 3341 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup-node-sandbox.js

Lines changed: 473 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup-sandbox.js

Lines changed: 462 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"@actions/exec": "^1.1.0",
3232
"@actions/io": "^1.1.1",
3333
"@aws-sdk/client-ecr": "^3.45.0",
34-
"@aws-sdk/client-ecr-public": "^3.45.0"
34+
"@aws-sdk/client-ecr-public": "^3.45.0",
35+
"proxy-agent": "^5.0.0"
3536
},
3637
"devDependencies": {
3738
"@types/jest": "^26.0.23",

src/aws.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as core from '@actions/core';
22
import {ECR} from '@aws-sdk/client-ecr';
33
import {ECRPUBLIC} from '@aws-sdk/client-ecr-public';
4+
import {NodeHttpHandler} from '@aws-sdk/node-http-handler';
5+
import ProxyAgent from 'proxy-agent';
46

57
const ecrRegistryRegex = /^(([0-9]{12})\.dkr\.ecr\.(.+)\.amazonaws\.com(.cn)?)(\/([^:]+)(:.+)?)?$/;
68

@@ -54,6 +56,20 @@ export const getRegistriesData = async (registry: string, username?: string, pas
5456
authTokenRequest['registryIds'] = accountIDs;
5557
}
5658

59+
let httpProxyAgent: any = null;
60+
const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY || '';
61+
if (httpProxy) {
62+
core.debug(`Using http proxy ${httpProxy}`);
63+
httpProxyAgent = new ProxyAgent(httpProxy);
64+
}
65+
66+
let httpsProxyAgent: any = null;
67+
const httpsProxy = process.env.https_proxy || process.env.HTTPS_PROXY || '';
68+
if (httpsProxy) {
69+
core.debug(`Using https proxy ${httpsProxy}`);
70+
httpsProxyAgent = new ProxyAgent(httpsProxy);
71+
}
72+
5773
const credentials =
5874
username && password
5975
? {
@@ -67,7 +83,11 @@ export const getRegistriesData = async (registry: string, username?: string, pas
6783
const ecrPublic = new ECRPUBLIC({
6884
customUserAgent: 'docker-login-action',
6985
credentials,
70-
region: region
86+
region: region,
87+
requestHandler: new NodeHttpHandler({
88+
httpAgent: httpProxyAgent,
89+
httpsAgent: httpsProxyAgent
90+
})
7191
});
7292
const authTokenResponse = await ecrPublic.getAuthorizationToken(authTokenRequest);
7393
if (!authTokenResponse.authorizationData || !authTokenResponse.authorizationData.authorizationToken) {
@@ -87,7 +107,11 @@ export const getRegistriesData = async (registry: string, username?: string, pas
87107
const ecr = new ECR({
88108
customUserAgent: 'docker-login-action',
89109
credentials,
90-
region: region
110+
region: region,
111+
requestHandler: new NodeHttpHandler({
112+
httpAgent: httpProxyAgent,
113+
httpsAgent: httpsProxyAgent
114+
})
91115
});
92116
const authTokenResponse = await ecr.getAuthorizationToken(authTokenRequest);
93117
if (!Array.isArray(authTokenResponse.authorizationData) || !authTokenResponse.authorizationData.length) {

0 commit comments

Comments
 (0)