diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go index b6f756a4ae..88a2118638 100644 --- a/routers/web/shared/actions/runners.go +++ b/routers/web/shared/actions/runners.go @@ -130,7 +130,7 @@ func RunnerDetailsEditPost(ctx *context.Context, runnerID, ownerID, repoID int64 form := web.GetForm(ctx).(*forms.EditRunnerForm) runner.Description = form.Description - runner.CustomLabels = strings.Split(form.CustomLabels, ",") + runner.CustomLabels = splitLabels(form.CustomLabels) err = actions_model.UpdateRunner(ctx, runner, "description", "custom_labels") if err != nil { @@ -182,3 +182,11 @@ func RunnerDeletePost(ctx *context.Context, runnerID int64, ctx.Flash.Success(ctx.Tr("runners.delete_runner_success")) ctx.Redirect(successRedirectTo) } + +func splitLabels(s string) []string { + labels := strings.Split(s, ",") + for i, v := range labels { + labels[i] = strings.TrimSpace(v) + } + return labels +}