mirror of
https://github.com/docker/login-action.git
synced 2025-04-27 17:16:35 +02:00
Fix tests
This commit is contained in:
parent
25aa6aa30c
commit
04f461cc60
4 changed files with 30 additions and 20 deletions
10
src/aws.ts
10
src/aws.ts
|
@ -10,15 +10,19 @@ export const getCLI = async (): Promise<string> => {
|
|||
return io.which('aws', true);
|
||||
};
|
||||
|
||||
export const getCLIVersion = async (): Promise<string | undefined> => {
|
||||
return execm.exec('aws', ['--version'], true).then(res => {
|
||||
export const getCLICmdOutput = async (args: string[]): Promise<string> => {
|
||||
return execm.exec(await getCLI(), args, true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(res.stderr);
|
||||
}
|
||||
return parseCLIVersion(res.stdout);
|
||||
return res.stdout;
|
||||
});
|
||||
};
|
||||
|
||||
export const getCLIVersion = async (): Promise<string | undefined> => {
|
||||
return parseCLIVersion(await getCLICmdOutput(['--version']));
|
||||
};
|
||||
|
||||
export const parseCLIVersion = async (stdout: string): Promise<string | undefined> => {
|
||||
const matches = /aws-cli\/([0-9.]+)/.exec(stdout);
|
||||
if (matches) {
|
||||
|
|
|
@ -47,13 +47,11 @@ export async function loginECR(registry: string, username: string, password: str
|
|||
|
||||
process.env.AWS_ACCESS_KEY_ID = username;
|
||||
process.env.AWS_SECRET_ACCESS_KEY = password;
|
||||
core.info(`⬇️ Retrieving docker login command through AWS CLI ${cliVersion}...`);
|
||||
await execm.exec(cliPath, ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(res.stderr);
|
||||
}
|
||||
|
||||
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(res.stdout, [], true).then(res => {
|
||||
execm.exec(stdout, [], true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(res.stderr);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue