From 70891fe94691f5f1d0cc1565f6c8c8e7da6a33b0 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 5 Dec 2023 19:47:43 +0800 Subject: [PATCH] test-your-pr: fix bot comment: actions/github-script is much better [skip ci] Signed-off-by: Jerry --- .github/workflows/test-your-pr.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-your-pr.yml b/.github/workflows/test-your-pr.yml index 0ef44ea..ec248a9 100644 --- a/.github/workflows/test-your-pr.yml +++ b/.github/workflows/test-your-pr.yml @@ -52,11 +52,16 @@ jobs: runs-on: ubuntu-20.04 if: ${{ always() && contains(needs.build.result, 'success') }} steps: - - uses: thollander/actions-comment-pull-request@v2 + - uses: actions/github-script@v7 with: - token: ${{ secrets.COMMENT_GITHUB_TOKEN }} - message: | - Congratulations! Your pull request passed the check. + github-token: ${{secrets.COMMENT_GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Congratulations! Your pull request passed the check.' + }) comment_failure: needs: [build] @@ -65,11 +70,18 @@ jobs: steps: - shell: bash run: | - echo ${{needs.build.outputs.generate_roa}} | base64 -d |tail > /tmp/buildjob_tail.log || echo 'internal error' > /tmp/buildjob_tail.log + echo ${{needs.build.outputs.generate_roa}} | base64 -d | tr -d '`' |tail > /tmp/buildjob_tail.log || echo 'internal error' > /tmp/buildjob_tail.log - - uses: thollander/actions-comment-pull-request@v2 + - uses: actions/github-script@v7 with: - token: ${{ secrets.COMMENT_GITHUB_TOKEN }} - filePath: /tmp/buildjob_tail.log + github-token: ${{secrets.COMMENT_GITHUB_TOKEN}} + script: | + const fs = require('fs') + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: fs.readFileSync('/tmp/buildjob_tail.log') + }) - run: false