3
0
Fork 0
mirror of https://gitea.com/docker/login-action.git synced 2024-11-25 19:09:38 +01:00
docker-login/src/main.ts
CrazyMax b9a4d91ee5
ecr input to specify whether the given registry is ECR
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-12-20 10:59:20 +01:00

28 lines
693 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) {
core.setFailed(error.message);
}
}
async function logout(): Promise<void> {
if (!stateHelper.logout) {
return;
}
await docker.logout(stateHelper.registry);
}
if (!stateHelper.IsPost) {
run();
} else {
logout();
}