GithubHelp home page GithubHelp logo

Comments (6)

Arondight avatar Arondight commented on July 23, 2024

I'm not sure is there a token for github-actions bot?

from commit-comment.

Arondight avatar Arondight commented on July 23, 2024

The problem is not github-actions bot, this action will failed if body is empty

from commit-comment.

Arondight avatar Arondight commented on July 23, 2024

The problem is not github-actions bot, this action will failed if body is empty

Fix in pull #59


Oh #59 didn't fix this but I still think it is necessary

from commit-comment.

peter-evans avatar peter-evans commented on July 23, 2024

Hi @Arondight

If you use the action with the default GITHUB_TOKEN then the comment will be created by the github actions bot user. If you use a PAT then the comment will be created by the user the PAT is associated with.

from commit-comment.

Arondight avatar Arondight commented on July 23, 2024

@peter-evans hi, can you tell me how to comment as a code block? I update action like this

diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml
index c2339f45..9cef2f9f 100644
--- a/.github/workflows/code_check.yml
+++ b/.github/workflows/code_check.yml
@@ -26,7 +26,7 @@ jobs:
         uses: peter-evans/commit-comment@v1
         if: ${{ '' != steps.check-code.outputs.result }}
         with:
-          body: ${{ steps.check-code.outputs.result }}
+          body: "```${{ steps.get-comment-body.outputs.body }}'%0A'```"
       - name: Error if check failed
         if: ${{ '' != steps.check-code.outputs.result }}
         run: exit -1

But i got

图片

I dont known how to do ...


I wrote wrong var, but in fact I get nothing from var in string

diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml
index 9cef2f9f..df4c3977 100644
--- a/.github/workflows/code_check.yml
+++ b/.github/workflows/code_check.yml
@@ -26,7 +26,7 @@ jobs:
         uses: peter-evans/commit-comment@v1
         if: ${{ '' != steps.check-code.outputs.result }}
         with:
-          body: "```${{ steps.get-comment-body.outputs.body }}'%0A'```"
+          body: "```${{ steps.get-comment-body.outputs.result }}\n```"
       - name: Error if check failed
         if: ${{ '' != steps.check-code.outputs.result }}
         run: exit -1

from commit-comment.

Arondight avatar Arondight commented on July 23, 2024

finally I done this

diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml
index c2339f4..576df98 100644
--- a/.github/workflows/code_check.yml
+++ b/.github/workflows/code_check.yml
@@ -7,7 +7,7 @@ on:
       - master
 
 jobs:
-  resources_update:
+  code_check:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout
@@ -17,16 +17,20 @@ jobs:
       - name: Check code
         id: check-code
         run: |
-          result=$(npm run --silent check || :)
-          result="${result//'%'/'%25'}"
-          result="${result//$'\n'/'%0A'}"
-          result="${result//$'\r'/'%0D'}"
-          echo ::set-output name=result::"$result"
+          check_output=$(npm run --silent check || :)
+          check_failed='true'
+          [[ -z "$check_output" ]] && check_failed='false'
+          check_output=$(echo -e "\`\`\`${check_output}\n\`\`\`")
+          check_output="${check_output//'%'/'%25'}"
+          check_output="${check_output//$'\n'/'%0A'}"
+          check_output="${check_output//$'\r'/'%0D'}"
+          echo ::set-output name=check_output::"$check_output"
+          echo ::set-output name=check_failed::"$check_failed"
       - name: Comment if check failed
         uses: peter-evans/commit-comment@v1
-        if: ${{ '' != steps.check-code.outputs.result }}
+        if: ${{ 'true' == steps.check-code.outputs.check_failed }}
         with:
-          body: ${{ steps.check-code.outputs.result }}
+          body: ${{ steps.check-code.outputs.check_output }}
       - name: Error if check failed
-        if: ${{ '' != steps.check-code.outputs.result }}
+        if: ${{ 'true' == steps.check-code.outputs.check_failed }}
         run: exit -1

from commit-comment.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.