Skip to content

Commit 0f9fb80

Browse files
authored
Merge pull request #13 from crazy-max/master
Take the password from stdin
2 parents 53f337d + b7800fe commit 0f9fb80

File tree

4 files changed

+15
-38
lines changed

4 files changed

+15
-38
lines changed

CHANGELOG.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

dist/index.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function logout(registry: string): Promise<void> {
1919
}
2020

2121
export async function loginStandard(registry: string, username: string, password: string): Promise<void> {
22-
let loginArgs: Array<string> = ['login', '--password', password];
22+
let loginArgs: Array<string> = ['login', '--password-stdin'];
2323
if (username) {
2424
loginArgs.push('--username', username);
2525
}
@@ -30,7 +30,7 @@ export async function loginStandard(registry: string, username: string, password
3030
} else {
3131
core.info(`🔑 Logging into DockerHub...`);
3232
}
33-
await execm.exec('docker', loginArgs, true).then(res => {
33+
await execm.exec('docker', loginArgs, true, password).then(res => {
3434
if (res.stderr != '' && !res.success) {
3535
throw new Error(res.stderr);
3636
}

src/exec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ export interface ExecResult {
77
stderr: string;
88
}
99

10-
export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
10+
export const exec = async (
11+
command: string,
12+
args: string[] = [],
13+
silent: boolean,
14+
stdin?: string
15+
): Promise<ExecResult> => {
1116
let stdout: string = '';
1217
let stderr: string = '';
1318

1419
const options: ExecOptions = {
1520
silent: silent,
16-
ignoreReturnCode: true
21+
ignoreReturnCode: true,
22+
input: Buffer.from(stdin || '')
1723
};
1824
options.listeners = {
1925
stdout: (data: Buffer) => {

0 commit comments

Comments
 (0)