lcov-reporter-action icon indicating copy to clipboard operation
lcov-reporter-action copied to clipboard

Change codecov reports from auto comment to file outputs

Open HackingGate opened this issue 3 years ago • 1 comments

Changes

Stop comment to pull requests and commits but output the HTML body as a file instead. Default output path is ./coverage/body.html.

Why

  1. This gives user more control of it.
  2. Less error-prone? (I got Bad credentials error before I create a fork. Move to actions/github-script solved my issue. Possible same issue found on #25)

How to try this pull request

- uses: HackingGate/lcov-reporter-action@7bf132b5f872f17fde607a37b7ca2308510abbb4

In your GitHub Workflow YAML file.

How to create a pull_request or commit comment

For example use actions/github-script.

This is the GitHub Workflow YAML I currently in use. Add it after HackingGate/lcov-reporter-action.

- uses: actions/github-script@v4
      with:
        script: |
          fs = require('fs');
          fs.readFile('./coverage/body.html', 'utf8', function (error,data) {
            if (error) {
              console.log(error)
            }
            if (context.eventName === "pull_request") {
              github.issues.createComment({
                issue_number: context.issue.number,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: data
              })
            } else if (context.eventName === "push") {
              github.repos.createCommitComment({
                commit_sha: context.sha,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: data
              })
            }
          });

HackingGate avatar Jun 18 '21 13:06 HackingGate