@@ -2,7 +2,7 @@ import * as core from '@actions/core';
22import { context } from '@actions/github' ;
33import { Octokit , RestEndpointMethodTypes } from '@octokit/rest' ;
44import { Commit , parseCommitMessage } from '../../../ng-dev/commit-message/parse.js' ;
5- import { managedLabels , targetLabels } from '../../../ng-dev/pr/common/labels/index.js' ;
5+ import { actionLabels , managedLabels , targetLabels } from '../../../ng-dev/pr/common/labels/index.js' ;
66import { ANGULAR_ROBOT , getAuthTokenFor , revokeActiveInstallationToken } from '../../utils.js' ;
77import { ManagedRepositories } from '../../../ng-dev/pr/common/labels/base.js' ;
88
@@ -85,6 +85,7 @@ class PullRequestLabeling {
8585 if ( this . pullRequestMetadata === undefined ) {
8686 return ;
8787 }
88+
8889 /** The base reference string, or target branch of the pull request. */
8990 const baseRef = this . pullRequestMetadata . base . ref ;
9091
@@ -100,6 +101,24 @@ class PullRequestLabeling {
100101 await this . addLabel ( targetLabels . TARGET_FEATURE . name ) ;
101102 }
102103 }
104+
105+ if ( this . pullRequestMetadata . draft && this . labels . has ( actionLabels . ACTION_MERGE . name ) ) {
106+ core . info ( `This pull request is still in draft mode, removing "action: merge" label` ) ;
107+ await this . removeLabel ( actionLabels . ACTION_MERGE . name ) ;
108+ }
109+ }
110+
111+ /** Remove the provided label to the pull request. */
112+ async removeLabel ( label : string ) {
113+ const { number : issue_number , owner, repo} = context . issue ;
114+ try {
115+ await this . git . issues . removeLabel ( { repo, owner, issue_number, name : label } ) ;
116+ core . info ( `Removed ${ label } label from PR #${ issue_number } ` ) ;
117+ this . labels . delete ( label ) ;
118+ } catch ( err ) {
119+ core . error ( `Failed to remove ${ label } label from PR #${ issue_number } ` ) ;
120+ core . debug ( err as string ) ;
121+ }
103122 }
104123
105124 /** Add the provided label to the pull request. */
0 commit comments