diff --git a/action.yml b/action.yml index fdeaf519..4dac2dc2 100644 --- a/action.yml +++ b/action.yml @@ -27,6 +27,10 @@ inputs: description: Set working directory if project is not in root folder required: false default: "./" + post-to: + description: Post the coverage report to either "comment" or "job-summary" + required: false + default: "comment" title: description: Title to add to the comment required: false diff --git a/dist/main.js b/dist/main.js index fb6adb61..b0fcd787 100644 --- a/dist/main.js +++ b/dist/main.js @@ -25484,6 +25484,7 @@ async function main$1() { core$1.getInput("filter-changed-files").toLowerCase() === "true"; const shouldDeleteOldComments = core$1.getInput("delete-old-comments").toLowerCase() === "true"; + const postTo = core$1.getInput("post-to").toLowerCase(); const title = core$1.getInput("title"); const raw = await fs.promises.readFile(lcovFile, "utf-8").catch(err => null); @@ -25530,20 +25531,29 @@ async function main$1() { await deleteOldComments(githubClient, options, github_1); } - if (github_1.eventName === "pull_request") { - await githubClient.issues.createComment({ - repo: github_1.repo.repo, - owner: github_1.repo.owner, - issue_number: github_1.payload.pull_request.number, - body: body, - }); - } else if (github_1.eventName === "push") { - await githubClient.repos.createCommitComment({ - repo: github_1.repo.repo, - owner: github_1.repo.owner, - commit_sha: options.commit, - body: body, - }); + switch (postTo) { + case "comment": + if (github_1.eventName === "pull_request") { + await githubClient.issues.createComment({ + repo: github_1.repo.repo, + owner: github_1.repo.owner, + issue_number: github_1.payload.pull_request.number, + body: body, + }); + } else if (github_1.eventName === "push") { + await githubClient.repos.createCommitComment({ + repo: github_1.repo.repo, + owner: github_1.repo.owner, + commit_sha: options.commit, + body: body, + }); + } + break + case "job-summary": + await core$1.summary.addRaw(body).write(); + break + default: + core$1.warning(`Unknown post-to value: '${postTo}'`); } } diff --git a/src/index.js b/src/index.js index 2efc5fb0..7a08ff3b 100644 --- a/src/index.js +++ b/src/index.js @@ -21,6 +21,7 @@ async function main() { core.getInput("filter-changed-files").toLowerCase() === "true" const shouldDeleteOldComments = core.getInput("delete-old-comments").toLowerCase() === "true" + const postTo = core.getInput("post-to").toLowerCase() const title = core.getInput("title") const raw = await fs.readFile(lcovFile, "utf-8").catch(err => null) @@ -67,20 +68,29 @@ async function main() { await deleteOldComments(githubClient, options, context) } - if (context.eventName === "pull_request") { - await githubClient.issues.createComment({ - repo: context.repo.repo, - owner: context.repo.owner, - issue_number: context.payload.pull_request.number, - body: body, - }) - } else if (context.eventName === "push") { - await githubClient.repos.createCommitComment({ - repo: context.repo.repo, - owner: context.repo.owner, - commit_sha: options.commit, - body: body, - }) + switch (postTo) { + case "comment": + if (context.eventName === "pull_request") { + await githubClient.issues.createComment({ + repo: context.repo.repo, + owner: context.repo.owner, + issue_number: context.payload.pull_request.number, + body: body, + }) + } else if (context.eventName === "push") { + await githubClient.repos.createCommitComment({ + repo: context.repo.repo, + owner: context.repo.owner, + commit_sha: options.commit, + body: body, + }) + } + break + case "job-summary": + await core.summary.addRaw(body).write() + break + default: + core.warning(`Unknown post-to value: '${postTo}'`) } }