Skip to content

Commit d648b82

Browse files
authored
Added logging for when event isn't a PR (#162)
* Added logging for when event isn't a PR * added output of npm ci
1 parent 903fd91 commit d648b82

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

dist/main/index.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ async function run() {
2828
const errorMessage = `The code coverage is too low: ${totalCoverage}. Expected at least ${minimumCoverage}.`;
2929
const isMinimumCoverageReached = totalCoverage >= minimumCoverage;
3030

31-
if (gitHubToken !== '' && events.includes(github.context.eventName)) {
31+
const hasGithubToken = gitHubToken !== '';
32+
const isPR = events.includes(github.context.eventName);
33+
34+
if (hasGithubToken && isPR) {
3235
const octokit = await github.getOctokit(gitHubToken);
3336
const summary = await summarize(coverageFile);
3437
const details = await detail(coverageFile, octokit);
@@ -42,9 +45,12 @@ async function run() {
4245
}
4346

4447
updateComment ? await upsertComment(body, commentHeaderPrefix, octokit) : await createComment(body, octokit);
45-
} else {
48+
} else if (!hasGithubToken) {
4649
core.info("github-token received is empty. Skipping writing a comment in the PR.");
4750
core.info("Note: This could happen even if github-token was provided in workflow file. It could be because your github token does not have permissions for commenting in target repo.")
51+
} else if (!isPR) {
52+
core.info("The event is not a pull request. Skipping writing a comment.");
53+
core.info("The event type is: " + github.context.eventName);
4854
}
4955

5056
core.setOutput("total-coverage", totalCoverage);

0 commit comments

Comments
 (0)