mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Support changing labels of Actions runner without re-registration (#24806)
close #24540 related: - Protocol: https://gitea.com/gitea/actions-proto-def/pulls/9 - Runner side: https://gitea.com/gitea/act_runner/pulls/201 changes: - Add column of `labels` to table `action_runner`, and combine the value of `agent_labels` and `custom_labels` column to `labels` column. - Store `labels` when registering `act_runner`. - Update `labels` when `act_runner` starting and calling `Declare`. - Users cannot modify the `custom labels` in edit page any more. other changes: - Store `version` when registering `act_runner`. - If runner is latest version, parse version from `Declare`. But older version runner still parse version from request header.
This commit is contained in:
@@ -6,7 +6,6 @@ package actions
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
@@ -126,9 +125,8 @@ func RunnerDetailsEditPost(ctx *context.Context, runnerID, ownerID, repoID int64
|
||||
|
||||
form := web.GetForm(ctx).(*forms.EditRunnerForm)
|
||||
runner.Description = form.Description
|
||||
runner.CustomLabels = splitLabels(form.CustomLabels)
|
||||
|
||||
err = actions_model.UpdateRunner(ctx, runner, "description", "custom_labels")
|
||||
err = actions_model.UpdateRunner(ctx, runner, "description")
|
||||
if err != nil {
|
||||
log.Warn("RunnerDetailsEditPost.UpdateRunner failed: %v, url: %s", err, ctx.Req.URL)
|
||||
ctx.Flash.Warning(ctx.Tr("actions.runners.update_runner_failed"))
|
||||
@@ -176,11 +174,3 @@ func RunnerDeletePost(ctx *context.Context, runnerID int64,
|
||||
"redirect": successRedirectTo,
|
||||
})
|
||||
}
|
||||
|
||||
func splitLabels(s string) []string {
|
||||
labels := strings.Split(s, ",")
|
||||
for i, v := range labels {
|
||||
labels[i] = strings.TrimSpace(v)
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
Reference in New Issue
Block a user