mirror of
https://gitee.com/actions-mirror/docker-login-action
synced 2024-11-23 20:30:41 +08:00
Take the password from stdin
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
53f337dbae
commit
6e236fe59d
9
dist/index.js
generated
vendored
9
dist/index.js
generated
vendored
@ -2908,12 +2908,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.exec = void 0;
|
exports.exec = void 0;
|
||||||
const actionsExec = __importStar(__webpack_require__(514));
|
const actionsExec = __importStar(__webpack_require__(514));
|
||||||
exports.exec = (command, args = [], silent) => __awaiter(void 0, void 0, void 0, function* () {
|
exports.exec = (command, args = [], silent, stdin) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
let stderr = '';
|
let stderr = '';
|
||||||
const options = {
|
const options = {
|
||||||
silent: silent,
|
silent: silent,
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true,
|
||||||
|
input: Buffer.from(stdin || '')
|
||||||
};
|
};
|
||||||
options.listeners = {
|
options.listeners = {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
@ -2995,7 +2996,7 @@ function logout(registry) {
|
|||||||
exports.logout = logout;
|
exports.logout = logout;
|
||||||
function loginStandard(registry, username, password) {
|
function loginStandard(registry, username, password) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let loginArgs = ['login', '--password', password];
|
let loginArgs = ['login', '--password-stdin'];
|
||||||
if (username) {
|
if (username) {
|
||||||
loginArgs.push('--username', username);
|
loginArgs.push('--username', username);
|
||||||
}
|
}
|
||||||
@ -3006,7 +3007,7 @@ function loginStandard(registry, username, password) {
|
|||||||
else {
|
else {
|
||||||
core.info(`🔑 Logging into DockerHub...`);
|
core.info(`🔑 Logging into DockerHub...`);
|
||||||
}
|
}
|
||||||
yield execm.exec('docker', loginArgs, true).then(res => {
|
yield execm.exec('docker', loginArgs, true, password).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ export async function logout(registry: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loginStandard(registry: string, username: string, password: string): Promise<void> {
|
export async function loginStandard(registry: string, username: string, password: string): Promise<void> {
|
||||||
let loginArgs: Array<string> = ['login', '--password', password];
|
let loginArgs: Array<string> = ['login', '--password-stdin'];
|
||||||
if (username) {
|
if (username) {
|
||||||
loginArgs.push('--username', username);
|
loginArgs.push('--username', username);
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ export async function loginStandard(registry: string, username: string, password
|
|||||||
} else {
|
} else {
|
||||||
core.info(`🔑 Logging into DockerHub...`);
|
core.info(`🔑 Logging into DockerHub...`);
|
||||||
}
|
}
|
||||||
await execm.exec('docker', loginArgs, true).then(res => {
|
await execm.exec('docker', loginArgs, true, password).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
|
10
src/exec.ts
10
src/exec.ts
@ -7,13 +7,19 @@ export interface ExecResult {
|
|||||||
stderr: string;
|
stderr: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
|
export const exec = async (
|
||||||
|
command: string,
|
||||||
|
args: string[] = [],
|
||||||
|
silent: boolean,
|
||||||
|
stdin?: string
|
||||||
|
): Promise<ExecResult> => {
|
||||||
let stdout: string = '';
|
let stdout: string = '';
|
||||||
let stderr: string = '';
|
let stderr: string = '';
|
||||||
|
|
||||||
const options: ExecOptions = {
|
const options: ExecOptions = {
|
||||||
silent: silent,
|
silent: silent,
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true,
|
||||||
|
input: Buffer.from(stdin || '')
|
||||||
};
|
};
|
||||||
options.listeners = {
|
options.listeners = {
|
||||||
stdout: (data: Buffer) => {
|
stdout: (data: Buffer) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user