login-action/src/main.ts
CrazyMax 4b59a429db
update to node 16
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-28 08:29:00 +01:00

29 lines
698 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 input: context.Inputs = context.getInputs();
stateHelper.setRegistry(input.registry);
stateHelper.setLogout(input.logout);
await docker.login(input.registry, input.username, input.password, input.ecr);
} catch (error: any) {
core.setFailed(error.message);
}
}
async function logout(): Promise<void> {
if (!stateHelper.logout) {
return;
}
await docker.logout(stateHelper.registry);
}
if (!stateHelper.IsPost) {
run();
} else {
logout();
}