github-actionsnpm-audit

How to leave the github actions run result in the PR comments


I want to leave the result of "run audit" as a PR comment, but I don't know how. I'd appreciate your help.

      - name: Run audit
        run: yarn audit

Solution

  • You can use one of the existing GitHub actions from Marketplace.

    One solution will be:

    - name: Run audit
      id: audit
      run: |
         log="$(yarn audit)"
         echo "::set-output name=log::$log"
    - name: Create or update comment
      uses: peter-evans/create-or-update-comment@v2
      with:
        issue-number: ${{ github.event.pull_request.number }}
        body: ${{ steps.audit.outputs.log }}