File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,14 +49,37 @@ jobs:
4949 with :
5050 github-token : ${{ secrets.GITHUB_TOKEN }}
5151 script : |
52- var fs = require('fs');
53- var issue_number = Number(fs.readFileSync('./NR'));
54- var content = fs.readFileSync('./result.txt');
55- if (content.toString().trim().length > 7) { // 7 because we have backquote + \n
52+ const fs = require('fs');
53+ const issue_number = Number(fs.readFileSync('./NR'));
54+ const content = fs.readFileSync('./result.txt').toString();
55+
56+ if (content.trim().length <= 7) { // 7 because we have backquote + \n
57+ return;
58+ }
59+
60+ const marker = '<!-- gnu-comment-bot -->';
61+ const body = `${marker}\nGNU testsuite comparison:\n\`\`\`\n${content}\n\`\`\``;
62+
63+ const { data: comments } = await github.rest.issues.listComments({
64+ ...context.repo,
65+ issue_number
66+ });
67+
68+ const existing = comments.find(c =>
69+ c.user.login === 'github-actions[bot]' &&
70+ c.body.includes(marker)
71+ );
72+
73+ if (existing) {
74+ await github.rest.issues.updateComment({
75+ ...context.repo,
76+ comment_id: existing.id,
77+ body
78+ });
79+ } else {
5680 await github.rest.issues.createComment({
57- owner: context.repo.owner,
58- repo: context.repo.repo,
59- issue_number: issue_number,
60- body: 'GNU testsuite comparison:\n```\n' + content + '```'
81+ ...context.repo,
82+ issue_number,
83+ body
6184 });
6285 }
You can’t perform that action at this time.
0 commit comments