Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
783ae9cac5 | ||
|
|
b1725c2c93 | ||
|
|
0a596b2e7a | ||
|
|
5d1ee94869 | ||
|
|
af63523ba5 | ||
|
|
72edfa6c2e | ||
|
|
2b7517a3b4 | ||
|
|
eed2509203 | ||
|
|
07573e7c18 | ||
|
|
99ffd0f38a | ||
|
|
dbcb813823 | ||
|
|
5bcb015ee6 | ||
|
|
b30b2f2d31 | ||
|
|
9087f1e6d6 | ||
|
|
0009830ea1 | ||
|
|
23255232d3 | ||
|
|
4ec1d4a769 | ||
|
|
5fc99ba47b | ||
|
|
e512bd59d1 | ||
|
|
a146c91b8f | ||
|
|
8ffd80ffa5 | ||
|
|
8305724bcf | ||
|
|
91264757e1 | ||
|
|
b472f5b276 | ||
|
|
9d876d6c33 |
@@ -0,0 +1,3 @@
|
||||
FROM docker:29.3@sha256:4d90f1f6c400315c2dba96d3ec93c01e64198395cbba04f79d12adce4f737029
|
||||
|
||||
ENTRYPOINT ["docker"]
|
||||
@@ -0,0 +1,15 @@
|
||||
name: Pull Docker image
|
||||
|
||||
description: Pull an image from a Docker container action
|
||||
|
||||
inputs:
|
||||
image:
|
||||
description: Image reference to pull
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: docker
|
||||
image: Dockerfile
|
||||
args:
|
||||
- pull
|
||||
- ${{ inputs.image }}
|
||||
@@ -106,11 +106,10 @@ jobs:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: DinD
|
||||
uses: docker://docker:29.3@sha256:4d90f1f6c400315c2dba96d3ec93c01e64198395cbba04f79d12adce4f737029
|
||||
name: Pull test image from Docker CLI container action
|
||||
uses: ./.github/actions/docker-pull
|
||||
with:
|
||||
entrypoint: docker
|
||||
args: pull ${{ env.GHCR_TEST_IMAGE }}
|
||||
image: ${{ env.GHCR_TEST_IMAGE }}
|
||||
-
|
||||
name: Pull test image
|
||||
run: |
|
||||
@@ -228,7 +227,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
-
|
||||
name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
@@ -256,7 +255,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
-
|
||||
name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
|
||||
with:
|
||||
role-to-assume: arn:aws:iam::175142243308:role/official_gha_cicd_login_action
|
||||
aws-region: us-east-1
|
||||
@@ -303,7 +302,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
-
|
||||
name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
@@ -332,7 +331,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
-
|
||||
name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
|
||||
with:
|
||||
role-to-assume: arn:aws:iam::175142243308:role/official_gha_cicd_login_action
|
||||
aws-region: us-east-1
|
||||
|
||||
@@ -35,12 +35,12 @@ jobs:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
-
|
||||
name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@e0647621c2984b5ed2f768cb892365bf2a616ad1 # v4.37.2
|
||||
uses: github/codeql-action/init@db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28 # v4.37.8
|
||||
with:
|
||||
languages: javascript-typescript
|
||||
build-mode: none
|
||||
-
|
||||
name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@e0647621c2984b5ed2f768cb892365bf2a616ad1 # v4.37.2
|
||||
uses: github/codeql-action/analyze@db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28 # v4.37.8
|
||||
with:
|
||||
category: "/language:javascript-typescript"
|
||||
|
||||
@@ -757,10 +757,10 @@ The following inputs can be used as `step.with` keys:
|
||||
|
||||
The following environment variables can be set as `step.env` keys:
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|-------------------------------|--------|---------|-----------------------------------------------------------------------------|
|
||||
| `DOCKERHUB_OIDC_CONNECTIONID` | String | | Docker Hub OIDC connection ID. Required for Docker Hub OIDC login |
|
||||
| `DOCKERHUB_OIDC_EXPIREIN` | Number | `300` | Docker Hub OIDC token lifetime in seconds. Must be between `300` and `3600` |
|
||||
| Name | Type | Default | Description |
|
||||
|-------------------------------|--------|---------|----------------------------------------------------------------------------------------------------|
|
||||
| `DOCKERHUB_OIDC_CONNECTIONID` | String | | Docker Hub OIDC connection ID. Required for Docker Hub OIDC login |
|
||||
| `DOCKERHUB_OIDC_EXPIREIN` | Number | `300` | Docker Hub OIDC token lifetime in seconds. Must be between `300` (5 minutes) and `21600` (6 hours) |
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -35,6 +35,87 @@ test('getAuthList uses the default Docker Hub registry when computing scoped con
|
||||
});
|
||||
});
|
||||
|
||||
test('getAuthList supports @ scopes appended to the registry config dir', async () => {
|
||||
process.env['INPUT_USERNAME'] = 'dbowie';
|
||||
process.env['INPUT_PASSWORD'] = 'groundcontrol';
|
||||
process.env['INPUT_SCOPE'] = '@push';
|
||||
process.env['INPUT_LOGOUT'] = 'false';
|
||||
const [auth] = getAuthList(getInputs());
|
||||
expect(auth).toMatchObject({
|
||||
configDir: path.join(Buildx.configDir, 'config', 'registry-1.docker.io') + '@push'
|
||||
});
|
||||
});
|
||||
|
||||
test('getAuthList supports repository scopes with appended actions', async () => {
|
||||
process.env['INPUT_USERNAME'] = 'dbowie';
|
||||
process.env['INPUT_PASSWORD'] = 'groundcontrol';
|
||||
process.env['INPUT_SCOPE'] = 'docker/buildx-bin@push';
|
||||
process.env['INPUT_LOGOUT'] = 'false';
|
||||
const [auth] = getAuthList(getInputs());
|
||||
expect(auth).toMatchObject({
|
||||
configDir: path.join(Buildx.configDir, 'config', 'registry-1.docker.io', 'docker', 'buildx-bin@push')
|
||||
});
|
||||
});
|
||||
|
||||
test('getAuthList supports comma-separated scope actions', async () => {
|
||||
process.env['INPUT_USERNAME'] = 'dbowie';
|
||||
process.env['INPUT_PASSWORD'] = 'groundcontrol';
|
||||
process.env['INPUT_SCOPE'] = 'docker/buildx-bin@pull,push';
|
||||
process.env['INPUT_LOGOUT'] = 'false';
|
||||
const [auth] = getAuthList(getInputs());
|
||||
expect(auth).toMatchObject({
|
||||
configDir: path.join(Buildx.configDir, 'config', 'registry-1.docker.io', 'docker', 'buildx-bin@pull,push')
|
||||
});
|
||||
});
|
||||
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
'../../../../work/leaked',
|
||||
'..',
|
||||
'foo/../../../../etc',
|
||||
'@../../../leaked',
|
||||
'foo/bar@../../../leaked',
|
||||
'@push@pull',
|
||||
'foo/bar@push@pull',
|
||||
'@push,',
|
||||
'@,push',
|
||||
'@pull,,push',
|
||||
'@Push',
|
||||
path.join(path.parse(Buildx.configDir).root, 'work', 'leaked')
|
||||
])('getAuthList rejects unsafe or unsupported scope path: %s', async scope => {
|
||||
expect(() => {
|
||||
getAuthList({
|
||||
registry: '',
|
||||
username: 'dbowie',
|
||||
password: 'groundcontrol',
|
||||
scope,
|
||||
ecr: '',
|
||||
logout: false,
|
||||
registryAuth: ''
|
||||
});
|
||||
}).toThrow(/Invalid scope/);
|
||||
});
|
||||
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
'../../../../work/leaked',
|
||||
'..',
|
||||
'foo/../../../../etc',
|
||||
path.join(path.parse(Buildx.configDir).root, 'work', 'leaked')
|
||||
])('getAuthList rejects unsafe registry path: %s', async registry => {
|
||||
expect(() => {
|
||||
getAuthList({
|
||||
registry,
|
||||
username: 'dbowie',
|
||||
password: 'groundcontrol',
|
||||
scope: '@push',
|
||||
ecr: '',
|
||||
logout: false,
|
||||
registryAuth: ''
|
||||
});
|
||||
}).toThrow(/Invalid registry/);
|
||||
});
|
||||
|
||||
test('getAuthList skips secret masking when registry-auth password is absent', async () => {
|
||||
const stdoutWriteSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
|
||||
const [auth] = getAuthList({
|
||||
|
||||
@@ -5,6 +5,7 @@ import {beforeEach, describe, expect, test, vi} from 'vitest';
|
||||
import * as dockerhub from '../src/dockerhub.js';
|
||||
|
||||
vi.mock('@actions/core', () => ({
|
||||
debug: vi.fn(),
|
||||
getIDToken: vi.fn(),
|
||||
info: vi.fn(),
|
||||
setSecret: vi.fn()
|
||||
@@ -83,13 +84,22 @@ describe('getOIDCToken', () => {
|
||||
expect(body.get('connection_id')).toBe(validConnectionID);
|
||||
expect(body.get('expires_in')).toBe('300');
|
||||
expect(setSecretMock).toHaveBeenCalledWith('hub-token');
|
||||
expect(core.info).toHaveBeenCalledWith('Docker Hub OIDC detected for docker.io');
|
||||
expect(core.info).toHaveBeenCalledWith('Retrieving GitHub OIDC token for Docker Hub');
|
||||
expect(core.info).toHaveBeenCalledWith('Exchanging GitHub OIDC token for Docker Hub token');
|
||||
expect(core.info).toHaveBeenCalledWith('Docker Hub OIDC token exchange succeeded');
|
||||
expect(core.debug).toHaveBeenCalledWith('Docker Hub OIDC token audience: https://identity.docker.com');
|
||||
expect(core.debug).toHaveBeenCalledWith('Docker Hub OIDC token expiration: 300s');
|
||||
expect(core.debug).toHaveBeenCalledWith('Sending Docker Hub OIDC token request to https://identity.docker.com/oauth/token');
|
||||
expect(core.debug).toHaveBeenCalledWith('Docker Hub OIDC token request returned status code 200');
|
||||
expect(core.debug).toHaveBeenCalledWith('Docker Hub OIDC token response status code: 200');
|
||||
});
|
||||
|
||||
test('uses custom token expiration', async () => {
|
||||
process.env.DOCKERHUB_OIDC_EXPIREIN = '900';
|
||||
process.env.DOCKERHUB_OIDC_EXPIREIN = '21600';
|
||||
await dockerhub.getOIDCToken('docker.io', 'dbowie');
|
||||
const body = new URLSearchParams(postSpy.mock.calls[0][1]);
|
||||
expect(body.get('expires_in')).toBe('900');
|
||||
expect(body.get('expires_in')).toBe('21600');
|
||||
});
|
||||
|
||||
test('uses stage identity host for stage registry', async () => {
|
||||
@@ -112,9 +122,9 @@ describe('getOIDCToken', () => {
|
||||
expect(postSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test.each(['not-a-number', '299', '3601'])('validates token expiration %p', async expiresIn => {
|
||||
test.each(['not-a-number', '299', '21601'])('validates token expiration %p', async expiresIn => {
|
||||
process.env.DOCKERHUB_OIDC_EXPIREIN = expiresIn;
|
||||
await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow(`Invalid DOCKERHUB_OIDC_EXPIREIN: ${expiresIn}. Must be between 300 and 3600`);
|
||||
await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow(`Invalid DOCKERHUB_OIDC_EXPIREIN: ${expiresIn}. Must be between 300 and 21600`);
|
||||
expect(getIDTokenMock).not.toHaveBeenCalled();
|
||||
expect(postSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
+119
-119
File diff suppressed because one or more lines are too long
+4
-4
File diff suppressed because one or more lines are too long
+23
-22
@@ -1913,8 +1913,8 @@ Apache License
|
||||
|
||||
The following npm packages may be included in this product:
|
||||
|
||||
- @aws-sdk/[email protected]1.0
|
||||
- @aws-sdk/[email protected]1.0
|
||||
- @aws-sdk/[email protected]5.0
|
||||
- @aws-sdk/[email protected]5.0
|
||||
|
||||
These packages each contain the following license:
|
||||
|
||||
@@ -2124,8 +2124,8 @@ Apache License
|
||||
|
||||
The following npm packages may be included in this product:
|
||||
|
||||
- @aws-sdk/[email protected]1
|
||||
- @smithy/core@3.29.6
|
||||
- @aws-sdk/[email protected]2
|
||||
- @smithy/core@3.30.0
|
||||
- @smithy/[email protected]
|
||||
|
||||
These packages each contain the following license:
|
||||
@@ -2396,11 +2396,12 @@ SOFTWARE.
|
||||
|
||||
-----------
|
||||
|
||||
The following npm package may be included in this product:
|
||||
The following npm packages may be included in this product:
|
||||
|
||||
- [email protected]
|
||||
- [email protected]
|
||||
|
||||
This package contains the following license:
|
||||
These packages each contain the following license:
|
||||
|
||||
(The MIT License)
|
||||
|
||||
@@ -3175,7 +3176,7 @@ software or this license, under any kind of legal claim.***
|
||||
|
||||
The following npm package may be included in this product:
|
||||
|
||||
- @aws-sdk/[email protected]5.3
|
||||
- @aws-sdk/[email protected]7.1
|
||||
|
||||
This package contains the following license:
|
||||
|
||||
@@ -3385,16 +3386,16 @@ Apache License
|
||||
|
||||
The following npm packages may be included in this product:
|
||||
|
||||
- @aws-sdk/[email protected].59
|
||||
- @aws-sdk/[email protected].4
|
||||
- @aws-sdk/[email protected]0
|
||||
- @aws-sdk/[email protected]88.0
|
||||
- @aws-sdk/[email protected].61
|
||||
- @aws-sdk/[email protected].6
|
||||
- @aws-sdk/[email protected]2
|
||||
- @aws-sdk/[email protected]95.0
|
||||
- @aws-sdk/[email protected]
|
||||
- @aws-sdk/[email protected]6
|
||||
- @smithy/[email protected]1
|
||||
- @smithy/[email protected].8
|
||||
- @smithy/[email protected].8
|
||||
- @smithy/[email protected].7
|
||||
- @aws-sdk/[email protected]7
|
||||
- @smithy/[email protected]4
|
||||
- @smithy/[email protected].11
|
||||
- @smithy/[email protected].11
|
||||
- @smithy/[email protected].10
|
||||
|
||||
These packages each contain the following license:
|
||||
|
||||
@@ -3604,9 +3605,9 @@ Apache License
|
||||
|
||||
The following npm packages may be included in this product:
|
||||
|
||||
- @aws-sdk/[email protected].59
|
||||
- @aws-sdk/[email protected].3
|
||||
- @aws-sdk/[email protected]5
|
||||
- @aws-sdk/[email protected].61
|
||||
- @aws-sdk/[email protected].5
|
||||
- @aws-sdk/[email protected]7
|
||||
|
||||
These packages each contain the following license:
|
||||
|
||||
@@ -3880,9 +3881,9 @@ END OF TERMS AND CONDITIONS
|
||||
|
||||
The following npm packages may be included in this product:
|
||||
|
||||
- @aws-sdk/[email protected]1
|
||||
- @aws-sdk/[email protected]6
|
||||
- @aws-sdk/[email protected]3
|
||||
- @aws-sdk/[email protected]3
|
||||
- @aws-sdk/[email protected]8
|
||||
- @aws-sdk/[email protected]5
|
||||
- @sigstore/[email protected]
|
||||
|
||||
These packages each contain the following license:
|
||||
|
||||
+3
-3
@@ -25,12 +25,12 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^3.0.1",
|
||||
"@actions/http-client": "^4.0.1",
|
||||
"@aws-sdk/client-ecr": "^3.1091.0",
|
||||
"@aws-sdk/client-ecr-public": "^3.1091.0",
|
||||
"@aws-sdk/client-ecr": "^3.1095.0",
|
||||
"@aws-sdk/client-ecr-public": "^3.1095.0",
|
||||
"@docker/actions-toolkit": "^0.94.0",
|
||||
"http-proxy-agent": "^9.1.0",
|
||||
"https-proxy-agent": "^9.1.0",
|
||||
"js-yaml": "^5.2.1",
|
||||
"js-yaml": "^5.2.2",
|
||||
"uuid": "^14.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
+26
-6
@@ -77,13 +77,33 @@ export function scopeToConfigDir(registry: string, scope?: string): string {
|
||||
if (scopeDisabled() || !scope || scope === '') {
|
||||
return '';
|
||||
}
|
||||
let configDir = path.join(Buildx.configDir, 'config', registry === 'docker.io' ? 'registry-1.docker.io' : registry);
|
||||
if (scope.startsWith('@')) {
|
||||
configDir += scope;
|
||||
} else {
|
||||
configDir = path.join(configDir, scope);
|
||||
const configRoot = path.resolve(Buildx.configDir, 'config');
|
||||
const registryDir = path.resolve(configRoot, registry === 'docker.io' ? 'registry-1.docker.io' : registry);
|
||||
if (!isChildPath(configRoot, registryDir)) {
|
||||
throw new Error(`Invalid registry '${registry}': resolved config path escapes the Buildx config directory`);
|
||||
}
|
||||
return configDir;
|
||||
const scopeParts = scope.split('@');
|
||||
if (scopeParts.length > 2) {
|
||||
throw new Error(`Invalid scope '${scope}': scope can contain at most one @ separator`);
|
||||
}
|
||||
const [scopePath, scopeActions] = scopeParts;
|
||||
if (scopeActions !== undefined && !/^[a-z]+(,[a-z]+)*$/.test(scopeActions)) {
|
||||
throw new Error(`Invalid scope '${scope}': scope actions must be lowercase names separated by commas`);
|
||||
}
|
||||
const scopeSuffix = scopeActions === undefined ? '' : `@${scopeActions}`;
|
||||
if (scopePath === '') {
|
||||
return `${registryDir}${scopeSuffix}`;
|
||||
}
|
||||
const configDir = path.resolve(registryDir, scopePath);
|
||||
if (!isChildPath(registryDir, configDir)) {
|
||||
throw new Error(`Invalid scope '${scope}': resolved config path escapes the Buildx config directory`);
|
||||
}
|
||||
return `${configDir}${scopeSuffix}`;
|
||||
}
|
||||
|
||||
function isChildPath(parent: string, child: string): boolean {
|
||||
const relativePath = path.relative(parent, child);
|
||||
return relativePath !== '' && relativePath !== '..' && !relativePath.startsWith(`..${path.sep}`) && !path.isAbsolute(relativePath);
|
||||
}
|
||||
|
||||
function scopeDisabled(): boolean {
|
||||
|
||||
+12
-1
@@ -15,7 +15,7 @@ interface OIDCTokenResponse {
|
||||
const registries = new Set(['', 'docker.io', 'registry-1.docker.io', 'registry-1-stage.docker.io', 'dhi.io']);
|
||||
const defaultExpiresIn = 300;
|
||||
const minExpiresIn = 300;
|
||||
const maxExpiresIn = 3600;
|
||||
const maxExpiresIn = 21600;
|
||||
const maxRetries = 5;
|
||||
|
||||
export const isDockerHubOIDC = (registry: string, password: string): boolean => {
|
||||
@@ -35,6 +35,10 @@ export const getOIDCToken = async (registry: string, username: string): Promise<
|
||||
const expiresIn = getExpiresIn();
|
||||
const identityHost = registry === 'registry-1-stage.docker.io' ? 'identity-stage.docker.com' : 'identity.docker.com';
|
||||
const audience = `https://${identityHost}`;
|
||||
core.info(`Docker Hub OIDC detected for ${registry || 'docker.io'}`);
|
||||
core.debug(`Docker Hub OIDC token audience: ${audience}`);
|
||||
core.debug(`Docker Hub OIDC token expiration: ${expiresIn}s`);
|
||||
core.info(`Retrieving GitHub OIDC token for Docker Hub`);
|
||||
const idToken = await core.getIDToken(audience);
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('github.com/docker/login-action', [], {
|
||||
headers: {
|
||||
@@ -49,10 +53,12 @@ export const getOIDCToken = async (registry: string, username: string): Promise<
|
||||
data.set('connection_id', connectionID);
|
||||
data.set('expires_in', expiresIn.toString());
|
||||
|
||||
core.info(`Exchanging GitHub OIDC token for Docker Hub token`);
|
||||
const resp = await postWithRetry(http, `https://${identityHost}/oauth/token`, data.toString());
|
||||
|
||||
const tokenResp = <OIDCTokenResponse>JSON.parse(await handleResponse(resp));
|
||||
core.setSecret(tokenResp.access_token);
|
||||
core.info(`Docker Hub OIDC token exchange succeeded`);
|
||||
|
||||
return {
|
||||
username,
|
||||
@@ -70,16 +76,20 @@ const getExpiresIn = (): number => {
|
||||
};
|
||||
|
||||
const postWithRetry = async (http: httpm.HttpClient, url: string, data: string): Promise<httpm.HttpClientResponse> => {
|
||||
core.debug(`Sending Docker Hub OIDC token request to ${url}`);
|
||||
let resp = await http.post(url, data);
|
||||
core.debug(`Docker Hub OIDC token request returned status code ${resp.message.statusCode || HttpCodes.InternalServerError}`);
|
||||
for (let attempt = 0; (resp.message.statusCode || HttpCodes.InternalServerError) === HttpCodes.TooManyRequests && attempt < maxRetries; attempt++) {
|
||||
const delay = parseRetryAfter(resp.message.headers['retry-after']);
|
||||
if (delay === null) {
|
||||
core.debug(`Docker Hub OIDC token request rate limited without retry-after header`);
|
||||
break;
|
||||
}
|
||||
await resp.readBody();
|
||||
core.info(`Docker Hub OIDC token request rate limited, retrying in ${delay}ms (attempt ${attempt + 1}/${maxRetries})`);
|
||||
await new Promise(resolve => setTimeout(resolve, delay));
|
||||
resp = await http.post(url, data);
|
||||
core.debug(`Docker Hub OIDC token request returned status code ${resp.message.statusCode || HttpCodes.InternalServerError}`);
|
||||
}
|
||||
return resp;
|
||||
};
|
||||
@@ -101,6 +111,7 @@ const parseRetryAfter = (value: string | string[] | undefined): number | null =>
|
||||
const handleResponse = async (resp: httpm.HttpClientResponse): Promise<string> => {
|
||||
const body = await resp.readBody();
|
||||
const statusCode = resp.message.statusCode || HttpCodes.InternalServerError;
|
||||
core.debug(`Docker Hub OIDC token response status code: ${statusCode}`);
|
||||
if (statusCode < HttpCodes.OK || statusCode >= HttpCodes.MultipleChoices) {
|
||||
throw parseError(statusCode, body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user