@@ -57,16 +57,19 @@ export default async function success(pluginConfig, context, { Octokit }) {
57
57
58
58
const errors = [ ] ;
59
59
60
- if ( successComment === false || isEmpty ( commits ) ) {
60
+ if (
61
+ ( successComment === false && releasedLabels === false ) ||
62
+ isEmpty ( commits )
63
+ ) {
61
64
if ( isEmpty ( commits ) ) {
62
65
logger . log ( "No commits found in release" ) ;
63
66
}
64
- logger . log ( "Skip commenting on issues and pull requests." ) ;
67
+ logger . log ( "Skip commenting / adding labels on issues and pull requests." ) ;
65
68
logger . warn (
66
69
`DEPRECATION: 'false' for 'successComment' is deprecated and will be removed in a future major version. Use 'successCommentCondition' instead.` ,
67
70
) ;
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." ) ;
70
73
} else {
71
74
const parser = issueParser (
72
75
"github" ,
@@ -202,23 +205,25 @@ export default async function success(pluginConfig, context, { Octokit }) {
202
205
return ;
203
206
}
204
207
205
- const body = successComment
206
- ? template ( successComment ) ( { ...context , issue } )
207
- : getSuccessComment ( issue , releaseInfos , nextRelease ) ;
208
208
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
+ }
222
227
223
228
if ( releasedLabels ) {
224
229
const labels = releasedLabels . map ( ( label ) =>
@@ -242,18 +247,18 @@ export default async function success(pluginConfig, context, { Octokit }) {
242
247
} catch ( error ) {
243
248
if ( error . status === 403 ) {
244
249
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.` ,
246
251
issue . number ,
247
252
) ;
248
253
} else if ( error . status === 404 ) {
249
254
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.` ,
251
256
issue . number ,
252
257
) ;
253
258
} else {
254
259
errors . push ( error ) ;
255
260
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.` ,
257
262
issue . number ,
258
263
) ;
259
264
// Don't throw right away and continue to update other issues
0 commit comments