mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
simplify code and add missing GITHUB_HEAD_REF
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -1,5 +1,5 @@
|
||||
name: Example workflow for Codecov
|
||||
on: [push]
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
52360
dist/index.js
vendored
52360
dist/index.js
vendored
File diff suppressed because one or more lines are too long
122
index.js
122
index.js
@@ -55,101 +55,43 @@ try {
|
||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||
GITHUB_REF: process.env.GITHUB_REF,
|
||||
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 (fail_ci) {
|
||||
exec
|
||||
.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(
|
||||
"-f", `${file}`
|
||||
);
|
||||
}
|
||||
|
||||
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 = () => {
|
||||
fs.unlink("codecov.sh", err => {
|
||||
if (err && fail_ci) {
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "test2",
|
||||
"version": "1.0.0",
|
||||
"name": "codecov-action",
|
||||
"version": "1.0.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user