2023-02-21 10:06:17 +01:00
|
|
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
|
|
|
|
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';
|
|
|
|
|
2023-02-21 10:06:17 +01:00
|
|
|
export async function main(): Promise<void> {
|
|
|
|
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);
|
2020-08-15 14:45:36 +02:00
|
|
|
}
|
|
|
|
|
2023-02-21 10:06:17 +01:00
|
|
|
async function post(): Promise<void> {
|
2020-08-15 14:45:36 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-02-21 10:06:17 +01:00
|
|
|
actionsToolkit.run(main, post);
|