From 804f70d8c56bfd07f2d40d6dba0e82fb0f648d7f Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Thu, 4 Apr 2024 08:35:08 +0400 Subject: [PATCH] Handle PR automations when quick succession of PR approved and merged (#4028) Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> --- automations/js/src/project_automation/prs.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/automations/js/src/project_automation/prs.mjs b/automations/js/src/project_automation/prs.mjs index ec24d3c0b79..975b53ecac8 100644 --- a/automations/js/src/project_automation/prs.mjs +++ b/automations/js/src/project_automation/prs.mjs @@ -84,7 +84,13 @@ export const main = async (octokit, core) => { if (eventName === 'pull_request_review') { if (pr.isDraft) { await prBoard.moveCard(prCard.id, prBoard.columns.Draft) - } else { + } else if (!pr.isMerged) { + // Don't touch merged PRs to avoid race condition when a PR is merged + // right after the review and is already in a merged state when + // re-retrieved by the workflow, even though the triggering event was the + // second review. + // In that case we want our handling of merged PRs to take precedence, + // rather than updating the status based on the second review. await syncReviews(core, pr, prBoard, prCard) } } else {