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

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