Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-09-05 18:26:35 +02:00
parent b614728cdc
commit 8474404dec
4 changed files with 8 additions and 11 deletions

View File

@@ -7,10 +7,10 @@ import * as docker from './docker';
import * as stateHelper from './state-helper';
interface Auth {
registry: string;
registry?: string;
username: string;
password: string;
ecr: string;
ecr?: string;
}
export async function main(): Promise<void> {
@@ -28,6 +28,7 @@ export async function main(): Promise<void> {
}
const add = yaml.load(inputs.add) as Auth[];
core.info(`add: ${JSON.stringify(add, null, 2)}`);
if (Array.isArray(add)) {
auths.push(...add);
}
@@ -46,11 +47,11 @@ export async function main(): Promise<void> {
throw new Error('No registry to login');
}
if (auths.length === 1) {
await docker.login(auths[0].registry, auths[0].username, auths[0].password, auths[0].ecr || 'auto');
await docker.login(auths[0].registry || 'docker.io', auths[0].username, auths[0].password, auths[0].ecr || 'auto');
} else {
for (const auth of auths) {
await core.group(`Login to ${auth.registry || 'docker.io'}`, async () => {
await docker.login(auth.registry, auth.username, auth.password, auth.ecr || 'auto');
await docker.login(auth.registry || 'docker.io', auth.username, auth.password, auth.ecr || 'auto');
});
}
}