simplify code and add missing GITHUB_HEAD_REF

This commit is contained in:
Armano
2020-02-07 22:24:55 +01:00
parent 66879ff350
commit 44ca3d2c84
4 changed files with 26186 additions and 26302 deletions

View File

@@ -1,5 +1,5 @@
name: Example workflow for Codecov name: Example workflow for Codecov
on: [push] on: [push, pull_request]
jobs: jobs:
run: run:
runs-on: ubuntu-latest runs-on: ubuntu-latest

52360
dist/index.js vendored

File diff suppressed because one or more lines are too long

122
index.js
View File

@@ -55,101 +55,43 @@ try {
GITHUB_ACTION: process.env.GITHUB_ACTION, GITHUB_ACTION: process.env.GITHUB_ACTION,
GITHUB_REF: process.env.GITHUB_REF, GITHUB_REF: process.env.GITHUB_REF,
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
GITHUB_SHA: process.env.GITHUB_SHA GITHUB_SHA: process.env.GITHUB_SHA,
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF
}; };
const execArgs = ["codecov.sh"];
if (file) { if (file) {
if (fail_ci) { execArgs.push(
exec "-f", `${file}`
.exec( );
"bash",
[
"codecov.sh",
"-f",
`${file}`,
"-n",
`${name}`,
"-F",
`${flags}`,
"-y",
`${yml}`,
"-Z"
],
options
)
.catch(err => {
core.setFailed(
`Codecov failed with the following error: ${err.message}`
);
})
.then(() => {
unlinkFile();
});
} else {
exec
.exec(
"bash",
[
"codecov.sh",
"-f",
`${file}`,
"-n",
`${name}`,
"-F",
`${flags}`,
"-y",
`${yml}`
],
options
)
.catch(err => {
core.warning(`Codecov warning: ${err.message}`);
})
.then(() => {
unlinkFile();
});
}
} else {
if (fail_ci) {
exec
.exec(
"bash",
[
"codecov.sh",
"-n",
`${name}`,
"-F",
`${flags}`,
"-y",
`${yml}`,
"-Z"
],
options
)
.catch(err => {
core.setFailed(
`Codecov failed with the following error: ${err.message}`
);
})
.then(() => {
unlinkFile();
});
} else {
exec
.exec(
"bash",
["codecov.sh", "-n", `${name}`, "-F", `${flags}`, "-y", `${yml}`],
options
)
.catch(err => {
core.warning(`Codecov warning: ${err.message}`);
})
.then(() => {
unlinkFile();
});
}
} }
execArgs.push(
"-n", `${name}`,
"-F", `${flags}`,
"-y", `${yml}`
);
if (fail_ci) {
execArgs.push(
"-Z"
);
}
exec.exec("bash", execArgs, options)
.catch(err => {
if (fail_ci) {
core.setFailed(
`Codecov failed with the following error: ${err.message}`
);
} else {
core.warning(`Codecov warning: ${err.message}`);
}
})
.then(() => {
unlinkFile();
});;
const unlinkFile = () => { const unlinkFile = () => {
fs.unlink("codecov.sh", err => { fs.unlink("codecov.sh", err => {
if (err && fail_ci) { if (err && fail_ci) {

4
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "test2", "name": "codecov-action",
"version": "1.0.0", "version": "1.0.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {