From 7725cbbb454036d44505e2cf7afaeaf5e4b83b4f Mon Sep 17 00:00:00 2001 From: SherkeyXD <253294679@qq.com> Date: Tue, 12 Dec 2023 13:59:53 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20pr-checker=E8=87=AA=E5=8A=A8=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E4=B9=8B=E5=89=8D=E7=9A=84=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-checker.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/pr-checker.yml b/.github/workflows/pr-checker.yml index b170794b72..bfc9550200 100644 --- a/.github/workflows/pr-checker.yml +++ b/.github/workflows/pr-checker.yml @@ -12,6 +12,26 @@ jobs: if: ${{ !github.event.pull_request.merged }} runs-on: ubuntu-latest steps: + - name: Cleanup Previous Comment + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number + }); + + const previousComment = comments.find(comment => comment.user.login === 'github-actions[bot]' && comment.body.includes('invalid commit(s)')); + if (previousComment) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: previousComment.id + }); + } + - name: Check Commits uses: actions/github-script@v7 with: