try using actions exec

This commit is contained in:
ibrahim0814
2019-11-18 22:51:40 -08:00
parent c4ca0425e1
commit 889584d6f9
17 changed files with 869 additions and 2 deletions

View File

@@ -1,6 +1,10 @@
const core = require('@actions/core');
const github = require('@actions/github');
const request = require('request');
const exec = require('@actions/exec');
//const execSh = require('./node_modules/exec-sh/lib/exec-sh');
const execFileSync = require('child_process').execFileSync;
// import { execFileSync } from 'child_process'; // replace ^ if using ES modules
@@ -26,6 +30,24 @@ try {
//const payload = JSON.stringify(github.context.payload, undefined, 2)
//console.log(`The event payload: ${payload}`);
let myOutput = '';
let myError = '';
const options = {};
options.listeners = {
stdout: (data) => {
myOutput += data.toString();
},
stderr: (data) => {
myError += data.toString();
}
};
options.env = {CODECOV_TOKEN: 'e0f9f29c-c2e4-4dd3-b440-0c2bc6937859', GITHUB_ACTION: process.env.GITHUB_ACTION, GITHUB_REF: process.env.GITHUB_REF, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_SHA: process.env.GITHUB_SHA};
exec.exec('bash', ['bash.sh'], options);
//execFileSync('bash',['bash.sh'], {shell: true, env:{CODECOV_TOKEN: 'e0f9f29c-c2e4-4dd3-b440-0c2bc6937859', GITHUB_ACTION: process.env.GITHUB_ACTION, GITHUB_REF: process.env.GITHUB_REF, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_SHA: process.env.GITHUB_SHA}});
request('https://codecov.io/bash', (error, response, body) => {
//console.log('error:', error);
@@ -47,10 +69,10 @@ try {
// })
body = body.split("\n").slice(8).join("\n")
//body = body.replace("#!/usr/bin/env bash", "#!/bin/sh")
execFileSync(body,[], {shell: true, env:{CODECOV_TOKEN: 'e0f9f29c-c2e4-4dd3-b440-0c2bc6937859', GITHUB_ACTION: process.env.GITHUB_ACTION, GITHUB_REF: process.env.GITHUB_REF, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_SHA: process.env.GITHUB_SHA}});
// const command = `bash ${body}`