简体   繁体   English

如何在github actions中获取yarn命令输出

[英]How to get yarn command output in github actions

Im working on adding the output of yarn audit as a PR comment.我正在努力将 yarn audit 的输出添加为 PR 评论。 The problem is that all the output of $log is not displayed.问题是没有显示 $log 的所有输出。

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现在评论只显示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.

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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM