mirror of
https://github.com/docker/login-action.git
synced 2025-04-19 01:26:45 +00:00
Handle AWS credentials
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
39ef12fb7a
commit
5df5104555
9 changed files with 82 additions and 47 deletions
|
@ -10,8 +10,8 @@ export interface Inputs {
|
|||
export function getInputs(): Inputs {
|
||||
return {
|
||||
registry: core.getInput('registry'),
|
||||
username: core.getInput('username', {required: true}),
|
||||
password: core.getInput('password', {required: true}),
|
||||
username: core.getInput('username'),
|
||||
password: core.getInput('password'),
|
||||
logout: core.getInput('logout')
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ export async function logout(registry: string): Promise<void> {
|
|||
}
|
||||
|
||||
export async function loginStandard(registry: string, username: string, password: string): Promise<void> {
|
||||
let loginArgs: Array<string> = ['login', '--password-stdin'];
|
||||
if (username) {
|
||||
loginArgs.push('--username', username);
|
||||
if (!username || !password) {
|
||||
throw new Error('Username and password required');
|
||||
}
|
||||
|
||||
let loginArgs: Array<string> = ['login', '--password-stdin'];
|
||||
loginArgs.push('--username', username);
|
||||
loginArgs.push(registry);
|
||||
|
||||
if (registry) {
|
||||
|
@ -44,8 +46,8 @@ export async function loginECR(registry: string, username: string, password: str
|
|||
const region = await aws.getRegion(registry);
|
||||
core.info(`💡 AWS ECR detected with ${region} region`);
|
||||
|
||||
process.env.AWS_ACCESS_KEY_ID = username;
|
||||
process.env.AWS_SECRET_ACCESS_KEY = password;
|
||||
process.env.AWS_ACCESS_KEY_ID = username || process.env.AWS_ACCESS_KEY_ID;
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue