mirror of
https://github.com/docker/login-action.git
synced 2025-06-29 04:24:14 +00:00
Handle AWS CLI v2
This commit is contained in:
parent
16d491f0ca
commit
d833f7c2ad
5 changed files with 58 additions and 30 deletions
|
@ -42,20 +42,20 @@ export async function loginStandard(registry: string, username: string, password
|
|||
export async function loginECR(registry: string, username: string, password: string): Promise<void> {
|
||||
const cliPath = await aws.getCLI();
|
||||
const cliVersion = await aws.getCLIVersion();
|
||||
const ecrRegion = await aws.getRegion(registry);
|
||||
core.info(`💡 AWS ECR registry detected with ${ecrRegion} region`);
|
||||
const region = await aws.getRegion(registry);
|
||||
core.info(`💡 AWS ECR registry detected with ${region} region`);
|
||||
|
||||
process.env.AWS_ACCESS_KEY_ID = username;
|
||||
process.env.AWS_SECRET_ACCESS_KEY = password;
|
||||
|
||||
core.info(`⬇️ Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
|
||||
aws.getCLICmdOutput(['ecr', 'get-login', '--region', ecrRegion, '--no-include-email']).then(stdout => {
|
||||
core.info(`🔑 Logging into ${registry}...`);
|
||||
execm.exec(stdout, [], true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(res.stderr);
|
||||
}
|
||||
core.info('🎉 Login Succeeded!');
|
||||
});
|
||||
const loginCmd = await aws.getECRLoginCmd(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!');
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue