switch to actions-toolkit implementation

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-02-21 10:06:17 +01:00
parent 3da7dc6e2b
commit af023e8f62
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
10 changed files with 272 additions and 88 deletions

View file

@ -1,28 +1,21 @@
import * as core from '@actions/core';
import * as actionsToolkit from '@docker/actions-toolkit';
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);
}
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);
}
async function logout(): Promise<void> {
async function post(): Promise<void> {
if (!stateHelper.logout) {
return;
}
await docker.logout(stateHelper.registry);
}
if (!stateHelper.IsPost) {
run();
} else {
logout();
}
actionsToolkit.run(main, post);