2020-08-15 14:45:36 +02:00
|
|
|
import * as core from '@actions/core';
|
2021-04-28 00:34:26 +02:00
|
|
|
import * as context from './context';
|
2020-08-20 16:40:33 +02:00
|
|
|
import * as docker from './docker';
|
2020-08-15 14:45:36 +02:00
|
|
|
import * as stateHelper from './state-helper';
|
|
|
|
|
2020-10-09 12:30:45 +02:00
|
|
|
export async function run(): Promise<void> {
|
2020-08-15 14:45:36 +02:00
|
|
|
try {
|
2021-12-20 10:59:11 +01:00
|
|
|
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);
|
2022-02-28 08:28:55 +01:00
|
|
|
} catch (error: any) {
|
2020-08-15 14:45:36 +02:00
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function logout(): Promise<void> {
|
|
|
|
if (!stateHelper.logout) {
|
|
|
|
return;
|
|
|
|
}
|
2020-08-20 16:40:33 +02:00
|
|
|
await docker.logout(stateHelper.registry);
|
2020-08-15 14:45:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!stateHelper.IsPost) {
|
|
|
|
run();
|
|
|
|
} else {
|
|
|
|
logout();
|
|
|
|
}
|