mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 06:36:45 +00:00
Workflow - check all comments to find previous bot comment (#9815)
This commit is contained in:
parent
116c91e9c5
commit
a994ad3642
26
.github/workflows/external-component-bot.yml
vendored
26
.github/workflows/external-component-bot.yml
vendored
@ -61,7 +61,8 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createComment(octokit, owner, repo, prNumber, esphomeChanges, componentChanges) {
|
async function createComment(octokit, owner, repo, prNumber, esphomeChanges, componentChanges) {
|
||||||
const commentMarker = "<!-- This comment was generated automatically by a GitHub workflow. -->";
|
const commentMarker = "<!-- This comment was generated automatically by the external-component-bot workflow. -->";
|
||||||
|
const legacyCommentMarker = "<!-- This comment was generated automatically by a GitHub workflow. -->";
|
||||||
let commentBody;
|
let commentBody;
|
||||||
if (esphomeChanges.length === 1) {
|
if (esphomeChanges.length === 1) {
|
||||||
commentBody = generateExternalComponentInstructions(prNumber, componentChanges, owner, repo);
|
commentBody = generateExternalComponentInstructions(prNumber, componentChanges, owner, repo);
|
||||||
@ -71,14 +72,23 @@ jobs:
|
|||||||
commentBody += `\n\n---\n(Added by the PR bot)\n\n${commentMarker}`;
|
commentBody += `\n\n---\n(Added by the PR bot)\n\n${commentMarker}`;
|
||||||
|
|
||||||
// Check for existing bot comment
|
// Check for existing bot comment
|
||||||
const comments = await github.rest.issues.listComments({
|
const comments = await github.paginate(
|
||||||
owner: owner,
|
github.rest.issues.listComments,
|
||||||
repo: repo,
|
{
|
||||||
issue_number: prNumber,
|
owner: owner,
|
||||||
});
|
repo: repo,
|
||||||
|
issue_number: prNumber,
|
||||||
|
per_page: 100,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const botComment = comments.data.find(comment =>
|
const sorted = comments.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at));
|
||||||
comment.body.includes(commentMarker)
|
|
||||||
|
const botComment = sorted.find(comment =>
|
||||||
|
(
|
||||||
|
comment.body.includes(commentMarker) ||
|
||||||
|
comment.body.includes(legacyCommentMarker)
|
||||||
|
) && comment.user.type === "Bot"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (botComment && botComment.body === commentBody) {
|
if (botComment && botComment.body === commentBody) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user