Handle Amazon ECR registries associated with other accounts

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-12-16 21:53:24 +01:00
parent 3b14bab101
commit d3160f671f
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
4 changed files with 77 additions and 54 deletions

View file

@ -55,13 +55,19 @@ export async function loginECR(registry: string, username: string, password: str
process.env.AWS_SECRET_ACCESS_KEY = password || process.env.AWS_SECRET_ACCESS_KEY;
core.info(`⬇️ Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
const loginCmd = await aws.getDockerLoginCmd(cliVersion, registry, region);
const loginCmds = await aws.getDockerLoginCmds(cliVersion, registry, region);
core.info(`🔑 Logging into ${registry}...`);
execm.exec(loginCmd, [], true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
core.info('🎉 Login Succeeded!');
loginCmds.forEach((loginCmd, index) => {
execm.exec(loginCmd, [], true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
if (loginCmds.length > 1) {
core.info(`🎉 Login Succeeded! (${index}/${loginCmds.length})`);
} else {
core.info('🎉 Login Succeeded!');
}
});
});
}