try using child process

This commit is contained in:
ibrahim0814 2019-11-12 11:56:20 -08:00
parent 29f35e3a5f
commit 3e70efe265

View file

@ -1,24 +1,39 @@
const core = require('@actions/core'); const core = require('@actions/core');
const github = require('@actions/github'); const github = require('@actions/github');
const { exec } = require('child_process');
try { try {
// `who-to-greet` input defined in action metadata file // `who-to-greet` input defined in action metadata file
const name = core.getInput('name'); const name = core.getInput('name');
console.log(`Hello ${name}!`); console.log(`Name: ${name}!`);
const token = core.getInput('token'); const token = core.getInput('token');
console.log(`Hello ${name}!`); console.log(`Token: ${token}!`);
const flags = core.getInput('flags'); const flags = core.getInput('flags');
console.log(`Hello ${name}!`); console.log(`Flags: ${flags}!`);
const file = core.getInput('file'); const file = core.getInput('file');
console.log(`Hello ${file}!`); console.log(`File: ${file}!`);
// Get the JSON webhook payload for the event that triggered the workflow // Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2) const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`); console.log(`The event payload: ${payload}`);
const command = `curl <(bash https://codecov.io) -t ${token} -n ${name} -F ${flags} -f ${file}`
exec(command, (err, stdout, stderr) => {
if (err) {
//some err occurred
console.error(err)
} else {
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
}
});
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }