clean error outputs

On error, just mark the error with `core.setFailed`, this is enough to
kill the process.

Replace child_process.execFileSync with '@actions/exec'.exec to be async
all the way.
This commit is contained in:
zimbatm 2021-01-02 20:06:59 +01:00
commit f22d9c7a0f
No known key found for this signature in database
GPG key ID: 71BAF6D40C1D63D7
2 changed files with 6 additions and 12 deletions

9
dist/main/index.js vendored
View file

@ -1033,7 +1033,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470));
const child_process_1 = __webpack_require__(129);
const coreCommand = __importStar(__webpack_require__(431));
const exec = __importStar(__webpack_require__(986));
exports.IsPost = !!process.env['STATE_isPost'];
@ -1076,20 +1075,18 @@ function setup() {
}
catch (error) {
core.setFailed(`Action failed with error: ${error}`);
throw (error);
}
});
}
function upload() {
return __awaiter(this, void 0, void 0, function* () {
core.startGroup('Cachix: upload');
try {
if (skipPush === 'true') {
core.info('Pushing is disabled as skipPush is set to true');
}
else if (signingKey !== "" || authToken !== "") {
core.startGroup('Cachix: pushing paths');
child_process_1.execFileSync(`${__dirname}/push-paths.sh`, [cachixExecutable, name], { stdio: 'inherit' });
core.endGroup();
yield exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name]);
}
else {
core.info('Pushing is disabled as signing key nor auth token are set.');
@ -1097,8 +1094,8 @@ function upload() {
}
catch (error) {
core.setFailed(`Action failed with error: ${error}`);
throw (error);
}
core.endGroup();
});
}
// Main

View file

@ -1,5 +1,4 @@
import * as core from '@actions/core';
import { execFileSync } from 'child_process';
import * as coreCommand from '@actions/core/lib/command'
import * as exec from '@actions/exec';
@ -48,25 +47,23 @@ async function setup() {
await exec.exec("sh", ["-c", `nix path-info --all | grep -v '\.drv$' > /tmp/store-path-pre-build`]);
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
throw (error);
}
}
async function upload() {
core.startGroup('Cachix: upload');
try {
if (skipPush === 'true') {
core.info('Pushing is disabled as skipPush is set to true');
} else if (signingKey !== "" || authToken !== "") {
core.startGroup('Cachix: pushing paths');
execFileSync(`${__dirname}/push-paths.sh`, [cachixExecutable, name], { stdio: 'inherit' });
core.endGroup();
await exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name]);
} else {
core.info('Pushing is disabled as signing key nor auth token are set.');
}
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
throw (error);
}
core.endGroup();
}
// Main