mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-23 20:27:02 +08:00
clean up, add other inputs
This commit is contained in:
98
index.js
98
index.js
@@ -1,28 +1,10 @@
|
||||
const core = require('@actions/core');
|
||||
const github = require('@actions/github');
|
||||
const request = require('request');
|
||||
|
||||
const exec = require('@actions/exec');
|
||||
|
||||
const tmp = require('tmp');
|
||||
|
||||
const temp = require('temp')
|
||||
const fs = require('fs')
|
||||
const util = require('util')
|
||||
const path = require('path')
|
||||
|
||||
|
||||
|
||||
|
||||
//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
|
||||
// the default is 'buffer'
|
||||
|
||||
//const { exec } = require('child_process');
|
||||
|
||||
try {
|
||||
// `who-to-greet` input defined in action metadata file
|
||||
|
||||
const name = core.getInput('name');
|
||||
console.log(`Name: ${name}`);
|
||||
|
||||
@@ -35,39 +17,11 @@ try {
|
||||
const file = core.getInput('file');
|
||||
console.log(`File: ${file}`);
|
||||
|
||||
// Get the JSON webhook payload for the event that triggered the workflow
|
||||
//const payload = JSON.stringify(github.context.payload, undefined, 2)
|
||||
//console.log(`The event payload: ${payload}`);
|
||||
|
||||
|
||||
|
||||
//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);
|
||||
//console.log('statusCode:', response && response.statusCode);
|
||||
//console.log('body:', body);
|
||||
// token = token.toString()
|
||||
|
||||
// execSh([`export CODECOV_TOKEN=${token}`, body], true, (err, stdout, stderr)=>{
|
||||
// //console.log("error: ", err);
|
||||
// console.log("stdout: ", stdout);
|
||||
// //console.log("stderr: ", stderr);
|
||||
|
||||
// })
|
||||
|
||||
// execSh(body, true, (err, stdout, stderr)=>{
|
||||
// //console.log("error: ", err);
|
||||
// console.log("stdout: ", stdout);
|
||||
// //console.log("stderr: ", stderr);
|
||||
|
||||
// })
|
||||
|
||||
//body = body.replace("#!/usr/bin/env bash", "#!/bin/sh")
|
||||
if (error) throw error
|
||||
let myOutput = '';
|
||||
let myError = '';
|
||||
fs.writeFile('codecov.sh', body, function(err) {
|
||||
fs.writeFile('codecov.sh', body, (err) => {
|
||||
if (err) throw err;
|
||||
const options = {};
|
||||
options.listeners = {
|
||||
@@ -78,45 +32,25 @@ try {
|
||||
myError += data.toString();
|
||||
}
|
||||
};
|
||||
options.env = {CODECOV_TOKEN: `${token}`, 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', ['codecov.sh'], options);
|
||||
options.env = {
|
||||
CODECOV_TOKEN: `${token}`,
|
||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||
GITHUB_REF: process.env.GITHUB_REF,
|
||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||
GITHUB_SHA: process.env.GITHUB_SHA
|
||||
};
|
||||
|
||||
if (file === '' ){
|
||||
exec.exec('bash', ['codecov.sh', '-f', `${file}`, '-n', `${name}`, '-F', `${flags}`, ], options);
|
||||
}else{
|
||||
exec.exec('bash', ['codecov.sh', `${name}`, '-F', `${flags}`, ], options);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// const command = `bash ${body}`
|
||||
// //const command = `bash ${body} -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}`);
|
||||
// }
|
||||
// });
|
||||
})
|
||||
|
||||
|
||||
// const command = `bash <(curl -s https://codecov.io/bash) -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) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
Reference in New Issue
Block a user