mirror of
https://github.com/docker/login-action.git
synced 2024-11-27 13:19:02 +00:00
7439f8b467
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
29 lines
669 B
TypeScript
29 lines
669 B
TypeScript
import * as core from '@actions/core';
|
|
import * as context from './context';
|
|
import * as docker from './docker';
|
|
import * as stateHelper from './state-helper';
|
|
|
|
export async function run(): Promise<void> {
|
|
try {
|
|
const {registry, username, password, logout} = context.getInputs();
|
|
stateHelper.setRegistry(registry);
|
|
stateHelper.setLogout(logout);
|
|
await docker.login(registry, username, password);
|
|
} catch (error) {
|
|
core.setFailed(error.message);
|
|
}
|
|
}
|
|
|
|
async function logout(): Promise<void> {
|
|
if (!stateHelper.logout) {
|
|
return;
|
|
}
|
|
await docker.logout(stateHelper.registry);
|
|
}
|
|
|
|
if (!stateHelper.IsPost) {
|
|
run();
|
|
} else {
|
|
logout();
|
|
}
|