mirror of
https://github.com/docker/login-action.git
synced 2026-04-14 04:44:47 +00:00
add opt-in skip for missing login credentials
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
292fe2d7ee
commit
27b3c4afc1
2 changed files with 79 additions and 17 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import * as core from '@actions/core';
|
||||
|
||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
||||
import {Util} from '@docker/actions-toolkit/lib/util.js';
|
||||
|
||||
import * as aws from './aws.js';
|
||||
import * as context from './context.js';
|
||||
|
|
@ -34,6 +35,10 @@ export async function logout(registry: string, configDir: string): Promise<void>
|
|||
}
|
||||
|
||||
export async function loginStandard(registry: string, username: string, password: string, scope?: string): Promise<void> {
|
||||
if ((!username || !password) && skipLoginIfMissingCredsEnabled()) {
|
||||
core.info(`Skipping login to ${registry}. Username or password is not set and DOCKER_LOGIN_SKIP_IF_MISSING_CREDS is enabled.`);
|
||||
return;
|
||||
}
|
||||
if (!username && !password) {
|
||||
throw new Error('Username and password required');
|
||||
}
|
||||
|
|
@ -79,3 +84,10 @@ async function loginExec(registry: string, username: string, password: string, s
|
|||
core.info('Login Succeeded!');
|
||||
});
|
||||
}
|
||||
|
||||
function skipLoginIfMissingCredsEnabled(): boolean {
|
||||
if (process.env.DOCKER_LOGIN_SKIP_IF_MISSING_CREDS) {
|
||||
return Util.parseBool(process.env.DOCKER_LOGIN_SKIP_IF_MISSING_CREDS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue