mirror of
https://github.com/docker/login-action.git
synced 2025-04-20 18:16:45 +00:00
Add example for Azure Container Registry (ACR)
This commit is contained in:
parent
1bd3567034
commit
e56233ce43
5 changed files with 52 additions and 20 deletions
10
src/aws.ts
10
src/aws.ts
|
@ -14,7 +14,7 @@ export const getCLI = async (): Promise<string> => {
|
|||
return io.which('aws', true);
|
||||
};
|
||||
|
||||
export const getCLICmdOutput = async (args: string[]): Promise<string> => {
|
||||
export const execCLI = async (args: string[]): Promise<string> => {
|
||||
return execm.exec(await getCLI(), args, true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(res.stderr);
|
||||
|
@ -27,7 +27,7 @@ export const getCLICmdOutput = async (args: string[]): Promise<string> => {
|
|||
};
|
||||
|
||||
export const getCLIVersion = async (): Promise<string> => {
|
||||
return parseCLIVersion(await getCLICmdOutput(['--version']));
|
||||
return parseCLIVersion(await execCLI(['--version']));
|
||||
};
|
||||
|
||||
export const parseCLIVersion = async (stdout: string): Promise<string> => {
|
||||
|
@ -38,13 +38,13 @@ export const parseCLIVersion = async (stdout: string): Promise<string> => {
|
|||
return semver.clean(matches[1]);
|
||||
};
|
||||
|
||||
export const getECRLoginCmd = async (cliVersion: string, registry: string, region: string): Promise<string> => {
|
||||
export const getDockerLoginCmd = async (cliVersion: string, registry: string, region: string): Promise<string> => {
|
||||
if (semver.satisfies(cliVersion, '>=2.0.0')) {
|
||||
return getCLICmdOutput(['ecr', 'get-login-password', '--region', region]).then(pwd => {
|
||||
return execCLI(['ecr', 'get-login-password', '--region', region]).then(pwd => {
|
||||
return `docker login --username AWS --password ${pwd} ${registry}`;
|
||||
});
|
||||
} else {
|
||||
return getCLICmdOutput(['ecr', 'get-login', '--region', region, '--no-include-email']).then(dockerLoginCmd => {
|
||||
return execCLI(['ecr', 'get-login', '--region', region, '--no-include-email']).then(dockerLoginCmd => {
|
||||
return dockerLoginCmd;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue