From a5bb1b42f5041ef9940e0e2dccb47e69df8b5283 Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Tue, 27 Feb 2024 19:02:43 +0100
Subject: [PATCH] Optimize the CI milestone reminder (#39196)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This PR narrows down the matching pattern for the milestone reminder to
only the descriptions that explicitly contain one of the closing keywords
followed by the issue (number).

To verify that the proposed solution works, please check:
- https://regexr.com/7sk94

Also see the list of the closing keywords as defined by GitHub.
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests

* Make the pattern case insensitive

Co-authored-by: Nicolò Pretto <info@npretto.com>
---
 .github/workflows/check-milestone.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/check-milestone.yml b/.github/workflows/check-milestone.yml
index f83950035cd..22b65a1183d 100644
--- a/.github/workflows/check-milestone.yml
+++ b/.github/workflows/check-milestone.yml
@@ -26,8 +26,8 @@ jobs:
 
             // the github API doesn't expose linked issues, so we have to parse the body ourselves
             function getLinkedIssueId(pull) {
-              // https://regexr.com/7mjnp
-              const match = pull.data.body.match(/(\/issues\/|#)(\d+)/);
+              // https://regexr.com/7sk94
+              const match = pull.data.body.match(/(close(s|d)?|fixe?(s|d)?|resolve(s|d)?) (#|https?:\/\/github.com\/.+\/issues\/)(\d+)/i);
               return match && match?.[2];
             }
 
-- 
GitLab