@@ -57,16 +57,19 @@ export default async function success(pluginConfig, context, { Octokit }) {
5757
5858 const errors = [ ] ;
5959
60- if ( successComment === false || isEmpty ( commits ) ) {
60+ if (
61+ ( successComment === false && releasedLabels === false ) ||
62+ isEmpty ( commits )
63+ ) {
6164 if ( isEmpty ( commits ) ) {
6265 logger . log ( "No commits found in release" ) ;
6366 }
64- logger . log ( "Skip commenting on issues and pull requests." ) ;
67+ logger . log ( "Skip commenting / adding labels on issues and pull requests." ) ;
6568 logger . warn (
6669 `DEPRECATION: 'false' for 'successComment' is deprecated and will be removed in a future major version. Use 'successCommentCondition' instead.` ,
6770 ) ;
68- } else if ( successCommentCondition === false ) {
69- logger . log ( "Skip commenting on issues and pull requests." ) ;
71+ } else if ( successCommentCondition === false && releasedLabels === false ) {
72+ logger . log ( "Skip commenting / adding labels on issues and pull requests." ) ;
7073 } else {
7174 const parser = issueParser (
7275 "github" ,
@@ -202,23 +205,25 @@ export default async function success(pluginConfig, context, { Octokit }) {
202205 return ;
203206 }
204207
205- const body = successComment
206- ? template ( successComment ) ( { ...context , issue } )
207- : getSuccessComment ( issue , releaseInfos , nextRelease ) ;
208208 try {
209- const comment = { owner, repo, issue_number : issue . number , body } ;
210- debug ( "create comment: %O" , comment ) ;
211- const {
212- data : { html_url : url } ,
213- } = await octokit . request (
214- "POST /repos/{owner}/{repo}/issues/{issue_number}/comments" ,
215- comment ,
216- ) ;
217- logger . log (
218- `Added comment to ${ issueOrPR } #%d: %s` ,
219- issue . number ,
220- url ,
221- ) ;
209+ if ( successComment !== false ) {
210+ const body = successComment
211+ ? template ( successComment ) ( { ...context , issue } )
212+ : getSuccessComment ( issue , releaseInfos , nextRelease ) ;
213+ const comment = { owner, repo, issue_number : issue . number , body } ;
214+ debug ( "create comment: %O" , comment ) ;
215+ const {
216+ data : { html_url : url } ,
217+ } = await octokit . request (
218+ "POST /repos/{owner}/{repo}/issues/{issue_number}/comments" ,
219+ comment ,
220+ ) ;
221+ logger . log (
222+ `Added comment to ${ issueOrPR } #%d: %s` ,
223+ issue . number ,
224+ url ,
225+ ) ;
226+ }
222227
223228 if ( releasedLabels ) {
224229 const labels = releasedLabels . map ( ( label ) =>
@@ -242,18 +247,18 @@ export default async function success(pluginConfig, context, { Octokit }) {
242247 } catch ( error ) {
243248 if ( error . status === 403 ) {
244249 logger . error (
245- `Not allowed to add a comment to the issue/PR #%d.` ,
250+ `Not allowed to add a comment/label to the issue/PR #%d.` ,
246251 issue . number ,
247252 ) ;
248253 } else if ( error . status === 404 ) {
249254 logger . error (
250- `Failed to add a comment to the issue/PR #%d as it doesn't exist.` ,
255+ `Failed to add a comment/label to the issue/PR #%d as it doesn't exist.` ,
251256 issue . number ,
252257 ) ;
253258 } else {
254259 errors . push ( error ) ;
255260 logger . error (
256- `Failed to add a comment to the issue/PR #%d.` ,
261+ `Failed to add a comment/label to the issue/PR #%d.` ,
257262 issue . number ,
258263 ) ;
259264 // Don't throw right away and continue to update other issues
0 commit comments