Skip to content

Commit

Permalink
feat: add addition override parameters (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
mad-it authored Jul 6, 2021
1 parent 8cbef1d commit 1301fde
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The action's step needs to run after your test suite has outputted an LCOV file.
| `parallel-finished` | _optional_ | Set to true in the last job, after the other parallel jobs steps have completed, this will send a webhook to Coveralls to set the build complete. |
| `coveralls-endpoint` | _optional_ | Hostname and protocol: `https://<host>`; Specifies a [Coveralls Enterprise](https://enterprise.coveralls.io/) hostname. |
| `base-path` | _optional_ | Path to the root folder of the project the coverage was collected in. Should be used in monorepos so that coveralls can process the LCOV correctly (e.g. packages/my-project) |
| `git-branch` | _optional_ | Default: GITHUB_REF environment variable. Override the branch name. |
| `git-commit` | _optional_ | Default: GITHUB_SHA environment variable. Override the commit sha. |

### Outputs:

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ inputs:
base-path:
description: 'The root folder of the project that originally ran the tests'
required: false
git-branch:
description: 'Override the branch name'
required: false
git-commit:
description: 'Override the commit sha'
required: false
outputs:
coveralls-api-result:
description: 'Result status of Coveralls API post.'
Expand Down
10 changes: 9 additions & 1 deletion lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ function run() {
console.log("Event Name: " + process.env.GITHUB_EVENT_NAME);
console.log(event);
}
if (process.env.GITHUB_EVENT_NAME == 'pull_request') {
const gitCommit = core.getInput('git-commit');
const gitBranch = core.getInput('git-branch');
if (gitCommit && gitCommit != '') {
process.env.COVERALLS_GIT_COMMIT = gitCommit;
}
if (gitBranch && gitBranch != '') {
process.env.COVERALLS_GIT_BRANCH = gitBranch;
}
if (process.env.GITHUB_EVENT_NAME == 'pull_request' || process.env.GITHUB_EVENT_NAME == 'pull_request_target') {
process.env.CI_PULL_REQUEST = JSON.parse(event).number;
}
const endpoint = core.getInput('coveralls-endpoint');
Expand Down
13 changes: 12 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ export async function run() {
console.log(event);
}

if (process.env.GITHUB_EVENT_NAME == 'pull_request') {
const gitCommit = core.getInput('git-commit');
const gitBranch = core.getInput('git-branch');

if (gitCommit && gitCommit != '') {
process.env.COVERALLS_GIT_COMMIT = gitCommit;
}

if (gitBranch && gitBranch != '') {
process.env.COVERALLS_GIT_BRANCH = gitBranch;
}

if (process.env.GITHUB_EVENT_NAME == 'pull_request' || process.env.GITHUB_EVENT_NAME == 'pull_request_target') {
process.env.CI_PULL_REQUEST = JSON.parse(event).number;
}

Expand Down

0 comments on commit 1301fde

Please sign in to comment.