0

Im working on adding the output of yarn audit as a PR comment. The problem is that all the output of $log is not displayed.

here is the code

      - name: Run audit
        id: audit
        run: |
          log="$(yarn audit)"
          echo "::set-output name=log::$log"

      - name: Create comment
        uses: peter-evans/create-or-update-comment@v2
        if: github.event_name == 'pull_request'
        with:
          issue-number: ${{ github.event.pull_request.number }}
          body: ${{ steps.audit.outputs.log }}

now comment is only shows yarn audit v1.22.19

The result I want is this.

yarn audit v1.22.19
0 vulnerabilities found - Packages audited: 768
✨  Done in 0.47s.
smooth97
  • 73
  • 2
  • 9
  • have you tried to redirect the output to a file, like `yarn audit > output.txt` then add the file as the body of the comment? – Matteo Oct 08 '22 at 13:55
  • 1
    @Matteo I solved it like this Thanks for your help!! ``` yarn audit > audit-log.txt log="$(cat output.txt)" log="${log//'%'/'%25'}" log="${log//$'\n'/'%0A'}" log="${log//$'\r'/'%0D'}" echo "::set-output name=log::$log" ``` – smooth97 Oct 09 '22 at 04:24
  • Feel free to post your solution as an answer so you can close the question – Matteo Oct 09 '22 at 06:55

1 Answers1

1

I solved it like this.

yarn audit > audit-log.txt log="$(cat output.txt)" log="${log//'%'/'%25'}" log="${log//$'\n'/'%0A'}" log="${log//$'\r'/'%0D'}" echo "::set-output name=log::$log"

smooth97
  • 73
  • 2
  • 9