@@ -345,6 +345,8 @@ func matchWorkflowsFilters(workflow *project_model.Workflow, issue *issues_model
345345}
346346
347347func executeWorkflowActions (ctx context.Context , workflow * project_model.Workflow , issue * issues_model.Issue ) {
348+ var toAddedLables , toRemovedLables []* issues_model.Label
349+
348350 for _ , action := range workflow .WorkflowActions {
349351 switch action .Type {
350352 case project_model .WorkflowActionTypeColumn :
@@ -373,10 +375,7 @@ func executeWorkflowActions(ctx context.Context, workflow *project_model.Workflo
373375 log .Error ("GetLabelByID: %v" , err )
374376 continue
375377 }
376- if err := issue_service .AddLabel (ctx , issue , user_model .NewProjectWorkflowsUser (), label ); err != nil {
377- log .Error ("AddLabels: %v" , err )
378- continue
379- }
378+ toAddedLables = append (toAddedLables , label )
380379 case project_model .WorkflowActionTypeRemoveLabels :
381380 labelID , _ := strconv .ParseInt (action .Value , 10 , 64 )
382381 if labelID == 0 {
@@ -388,12 +387,7 @@ func executeWorkflowActions(ctx context.Context, workflow *project_model.Workflo
388387 log .Error ("GetLabelByID: %v" , err )
389388 continue
390389 }
391- if err := issue_service .RemoveLabel (ctx , issue , user_model .NewProjectWorkflowsUser (), label ); err != nil {
392- if ! issues_model .IsErrRepoLabelNotExist (err ) {
393- log .Error ("RemoveLabels: %v" , err )
394- }
395- continue
396- }
390+ toRemovedLables = append (toRemovedLables , label )
397391 case project_model .WorkflowActionTypeIssueState :
398392 if strings .EqualFold (action .Value , "reopen" ) {
399393 if issue .IsClosed {
@@ -414,4 +408,10 @@ func executeWorkflowActions(ctx context.Context, workflow *project_model.Workflo
414408 log .Error ("Unsupported action type: %s" , action .Type )
415409 }
416410 }
411+
412+ if len (toAddedLables )+ len (toRemovedLables ) > 0 {
413+ if err := issue_service .AddRemoveLabels (ctx , issue , user_model .NewProjectWorkflowsUser (), toAddedLables , toRemovedLables ); err != nil {
414+ log .Error ("AddRemoveLabels: %v" , err )
415+ }
416+ }
417417}
0 commit comments