2020-08-15 12:45:36 +00:00
|
|
|
import * as core from '@actions/core';
|
2021-04-27 22:34:26 +00:00
|
|
|
import * as context from './context';
|
2020-08-20 14:40:33 +00:00
|
|
|
import * as docker from './docker';
|
2020-08-15 12:45:36 +00:00
|
|
|
import * as stateHelper from './state-helper';
|
|
|
|
|
2020-10-09 10:30:45 +00:00
|
|
|
export async function run(): Promise<void> {
|
2020-08-15 12:45:36 +00:00
|
|
|
try {
|
2021-04-27 22:34:26 +00:00
|
|
|
const {registry, username, password, logout} = context.getInputs();
|
2020-10-09 10:30:45 +00:00
|
|
|
stateHelper.setRegistry(registry);
|
|
|
|
stateHelper.setLogout(logout);
|
|
|
|
await docker.login(registry, username, password);
|
2020-08-15 12:45:36 +00:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function logout(): Promise<void> {
|
|
|
|
if (!stateHelper.logout) {
|
|
|
|
return;
|
|
|
|
}
|
2020-08-20 14:40:33 +00:00
|
|
|
await docker.logout(stateHelper.registry);
|
2020-08-15 12:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!stateHelper.IsPost) {
|
|
|
|
run();
|
|
|
|
} else {
|
|
|
|
logout();
|
|
|
|
}
|