From 9ff37e09c06fea705145e665fa5bd48b0753e3a2 Mon Sep 17 00:00:00 2001 From: Alex Ilgayev Date: Thu, 16 Nov 2023 13:29:18 +0200 Subject: [PATCH] chore(attest): run with sudo if possible --- attest/dist/index.js | 40 +++++++++++++++++++++++++++++++++++----- attest/index.js | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 70 insertions(+), 10 deletions(-) diff --git a/attest/dist/index.js b/attest/dist/index.js index 7d47826..2167dbe 100644 --- a/attest/dist/index.js +++ b/attest/dist/index.js @@ -10896,13 +10896,43 @@ async function run(config) { }; if (config.cimon.releasePath != '') { - await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec( - 'bash', - [CIMON_SCRIPT_PATH, CIMON_SUBCMD, config.cimon.releasePath], - options + _actions_core__WEBPACK_IMPORTED_MODULE_0__.info( + `Running Cimon from release path: ${config.cimon.releasePath}` ); + if (sudo) { + retval = await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec( + 'sudo', + [ + '-E', + 'sh', + CIMON_SCRIPT_PATH, + CIMON_SUBCMD, + config.cimon.releasePath, + ], + options + ); + } else { + retval = await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec( + 'sh', + [CIMON_SCRIPT_PATH, CIMON_SUBCMD, config.cimon.releasePath], + options + ); + } } else { - await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec('bash', [CIMON_SCRIPT_PATH, CIMON_SUBCMD], options); + _actions_core__WEBPACK_IMPORTED_MODULE_0__.info('Running Cimon from latest release path'); + if (sudo) { + retval = await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec( + 'sudo', + ['-E', 'sh', CIMON_SCRIPT_PATH, CIMON_SUBCMD], + options + ); + } else { + retval = await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec( + 'sh', + [CIMON_SCRIPT_PATH, CIMON_SUBCMD], + options + ); + } } fs__WEBPACK_IMPORTED_MODULE_5__.rmSync(CIMON_SCRIPT_PATH); diff --git a/attest/index.js b/attest/index.js index a38fe9e..98842cb 100644 --- a/attest/index.js +++ b/attest/index.js @@ -70,13 +70,43 @@ async function run(config) { }; if (config.cimon.releasePath != '') { - await exec.exec( - 'bash', - [CIMON_SCRIPT_PATH, CIMON_SUBCMD, config.cimon.releasePath], - options + core.info( + `Running Cimon from release path: ${config.cimon.releasePath}` ); + if (sudo) { + retval = await exec.exec( + 'sudo', + [ + '-E', + 'sh', + CIMON_SCRIPT_PATH, + CIMON_SUBCMD, + config.cimon.releasePath, + ], + options + ); + } else { + retval = await exec.exec( + 'sh', + [CIMON_SCRIPT_PATH, CIMON_SUBCMD, config.cimon.releasePath], + options + ); + } } else { - await exec.exec('bash', [CIMON_SCRIPT_PATH, CIMON_SUBCMD], options); + core.info('Running Cimon from latest release path'); + if (sudo) { + retval = await exec.exec( + 'sudo', + ['-E', 'sh', CIMON_SCRIPT_PATH, CIMON_SUBCMD], + options + ); + } else { + retval = await exec.exec( + 'sh', + [CIMON_SCRIPT_PATH, CIMON_SUBCMD], + options + ); + } } fs.rmSync(CIMON_SCRIPT_PATH);