From 33cbe0735a6982bc57aa791b94ba3485f22fe657 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Mon, 26 Aug 2024 14:58:48 +0200 Subject: [PATCH] chore(ci): update kernel-testing related matrix comment if already existent. Signed-off-by: Federico Di Pierro --- .../create-comment-kernel-testing.yml | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-comment-kernel-testing.yml b/.github/workflows/create-comment-kernel-testing.yml index e42a056fbc..60d7a6876a 100644 --- a/.github/workflows/create-comment-kernel-testing.yml +++ b/.github/workflows/create-comment-kernel-testing.yml @@ -42,13 +42,34 @@ jobs: uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} + # Taken from https://github.com/actions/github-script/blob/main/.github/workflows/pull-request-test.yml script: | var fs = require('fs'); var issue_number = Number(fs.readFileSync('./NR')); var comment_body = fs.readFileSync('./COMMENT'); - await github.rest.issues.createComment({ + + // Get the existing comments. + const {data: comments} = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue_number, - body: comment_body.toString('utf8') }); + + // Find any comment already made by the bot. + const botComment = comments.find(comment => comment.user.id === 41898282 && comment.body.includes('# X64 kernel testing matrix')); + + if (botComment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: comment_body.toString('utf8') + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: comment_body.toString('utf8') + }); + }