3
0
Fork 0
mirror of https://gitea.com/docker/login-action.git synced 2024-11-26 19:39:39 +01:00

Builtin exec

This commit is contained in:
CrazyMax 2020-08-20 16:14:02 +02:00
parent b7cd11b1fa
commit da3da99964
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
2 changed files with 13 additions and 10 deletions

11
dist/index.js generated vendored
View file

@ -1074,8 +1074,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87)); const os = __importStar(__webpack_require__(87));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(986));
const ecr = __importStar(__webpack_require__(34)); const ecr = __importStar(__webpack_require__(34));
const exec = __importStar(__webpack_require__(807)); const execm = __importStar(__webpack_require__(807));
const stateHelper = __importStar(__webpack_require__(153)); const stateHelper = __importStar(__webpack_require__(153));
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1090,12 +1091,12 @@ function run() {
const username = core.getInput('username'); const username = core.getInput('username');
const password = core.getInput('password', { required: true }); const password = core.getInput('password', { required: true });
if (yield ecr.isECR(registry)) { if (yield ecr.isECR(registry)) {
yield exec.exec('aws', ['--version'], false); yield exec.exec('aws', ['--version']);
const ecrRegion = yield ecr.getRegion(registry); const ecrRegion = yield ecr.getRegion(registry);
process.env.AWS_ACCESS_KEY_ID = username; process.env.AWS_ACCESS_KEY_ID = username;
process.env.AWS_SECRET_ACCESS_KEY = password; process.env.AWS_SECRET_ACCESS_KEY = password;
core.info(`🔑 Logging into AWS ECR region ${ecrRegion}...`); core.info(`🔑 Logging into AWS ECR region ${ecrRegion}...`);
yield exec.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => { yield execm.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
throw new Error(res.stderr); throw new Error(res.stderr);
} }
@ -1114,7 +1115,7 @@ function run() {
else { else {
core.info(`🔑 Logging into DockerHub...`); core.info(`🔑 Logging into DockerHub...`);
} }
yield exec.exec('docker', loginArgs, true).then(res => { yield execm.exec('docker', loginArgs, true).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
throw new Error(res.stderr); throw new Error(res.stderr);
} }
@ -1132,7 +1133,7 @@ function logout() {
if (!stateHelper.logout) { if (!stateHelper.logout) {
return; return;
} }
yield exec.exec('docker', ['logout', stateHelper.registry], false).then(res => { yield execm.exec('docker', ['logout', stateHelper.registry], false).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
core.warning(res.stderr); core.warning(res.stderr);
} }

View file

@ -1,7 +1,9 @@
import * as os from 'os'; import * as os from 'os';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as ecr from './ecr'; import * as ecr from './ecr';
import * as exec from './exec'; import * as execm from './exec';
import * as stateHelper from './state-helper'; import * as stateHelper from './state-helper';
async function run(): Promise<void> { async function run(): Promise<void> {
@ -19,13 +21,13 @@ async function run(): Promise<void> {
const password: string = core.getInput('password', {required: true}); const password: string = core.getInput('password', {required: true});
if (await ecr.isECR(registry)) { if (await ecr.isECR(registry)) {
await exec.exec('aws', ['--version'], false); await exec.exec('aws', ['--version']);
const ecrRegion = await ecr.getRegion(registry); const ecrRegion = await ecr.getRegion(registry);
process.env.AWS_ACCESS_KEY_ID = username; process.env.AWS_ACCESS_KEY_ID = username;
process.env.AWS_SECRET_ACCESS_KEY = password; process.env.AWS_SECRET_ACCESS_KEY = password;
core.info(`🔑 Logging into AWS ECR region ${ecrRegion}...`); core.info(`🔑 Logging into AWS ECR region ${ecrRegion}...`);
await exec.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => { await execm.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
throw new Error(res.stderr); throw new Error(res.stderr);
} }
@ -43,7 +45,7 @@ async function run(): Promise<void> {
} else { } else {
core.info(`🔑 Logging into DockerHub...`); core.info(`🔑 Logging into DockerHub...`);
} }
await exec.exec('docker', loginArgs, true).then(res => { await execm.exec('docker', loginArgs, true).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
throw new Error(res.stderr); throw new Error(res.stderr);
} }
@ -59,7 +61,7 @@ async function logout(): Promise<void> {
if (!stateHelper.logout) { if (!stateHelper.logout) {
return; return;
} }
await exec.exec('docker', ['logout', stateHelper.registry], false).then(res => { await execm.exec('docker', ['logout', stateHelper.registry], false).then(res => {
if (res.stderr != '' && !res.success) { if (res.stderr != '' && !res.success) {
core.warning(res.stderr); core.warning(res.stderr);
} }