This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch v4
in repository https://gitbox.apache.org/repos/asf/maven-gh-actions-shared.git


The following commit(s) were added to refs/heads/v4 by this push:
     new 11933bd  Add comment when a problem occurs in PR Automation (#171)
11933bd is described below

commit 11933bd95e3e8858dd3469995b3f60e9e60739f1
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Thu Jun 26 11:14:02 2025 +0200

    Add comment when a problem occurs in PR Automation (#171)
    
    * Add comment when a problem occurs in PR Automation
    
    * apply messages from review
---
 .github/workflows/pr-automation.yml | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/pr-automation.yml 
b/.github/workflows/pr-automation.yml
index 1f1b0b9..4ae4413 100644
--- a/.github/workflows/pr-automation.yml
+++ b/.github/workflows/pr-automation.yml
@@ -73,14 +73,28 @@ jobs:
             const branch = context.payload.pull_request.base.ref
             
             if (milestones.data.length == 0) {
-              throw new Error('There are no open milestones ... please create 
one')
+              await github.rest.issues.createComment({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                issue_number: context.issue.number,
+                body: '@' + context.payload.pull_request.merged_by.login +
+                ' The PR can't be associated to a milestone, because there is 
no open milestone. Please create a new milestone before merge.'
+              });
+              throw new Error('The PR can't be associated to a milestone, 
because there is no open milestone. Please create a new milestone before 
merge.')
             }
 
             var milestone;
             if (milestones.data.length > 1) {
               milestone = milestones.data.find(({description}) => 
description?.includes('branch: ' + branch));
               if (!milestone) {
-                throw new Error('There are more then oen open milestones ... 
please add a "branch: ' + branch + '" to description in one milestone');
+                await github.rest.issues.createComment({
+                  owner: context.repo.owner,
+                  repo: context.repo.repo,
+                  issue_number: context.issue.number,
+                  body: '@' + context.payload.pull_request.merged_by.login +
+                  ' The PR can't be associated to a milestone, because there 
are multiple open milestones. Please add the text "branch: ' + branch + '" to 
the description to the milestone where this PR belongs to.'
+                });
+                throw new Error('The PR can't be associated to a milestone, 
because there are multiple open milestones. Please add the text "branch: ' + 
branch + '" to the description to the milestone where this PR belongs to.');
               }
             } else {
               milestone = milestones.data[0];

Reply via email to