mirror of
https://github.com/docker/login-action.git
synced 2025-04-20 01:56:45 +00:00
switch to actions-toolkit implementation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
3da7dc6e2b
commit
af023e8f62
10 changed files with 272 additions and 88 deletions
25
src/main.ts
25
src/main.ts
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue