diff --git a/cmd/actions.go b/cmd/actions.go index 5b1f427cf9f..e0742f6e7eb 100644 --- a/cmd/actions.go +++ b/cmd/actions.go @@ -83,9 +83,9 @@ func runSetActionsRunnerToken(c *cli.Context) error { setting.MustInstalled() scope := c.String("scope") - putToken := c.String("token") + token := c.String("token") - respText, extra := private.SetActionsRunnerToken(ctx, scope, putToken) + respText, extra := private.SetActionsRunnerToken(ctx, scope, token) if extra.HasError() { return handleCliResponseExtra(extra) } diff --git a/modules/private/actions.go b/modules/private/actions.go index 09135eb543f..0f144170b1a 100644 --- a/modules/private/actions.go +++ b/modules/private/actions.go @@ -10,8 +10,7 @@ import ( ) type GenerateTokenRequest struct { - Scope string - PutToken string + Scope string } // GenerateActionsRunnerToken calls the internal GenerateActionsRunnerToken function diff --git a/routers/private/actions.go b/routers/private/actions.go index 8424c610d54..a3646e1340a 100644 --- a/routers/private/actions.go +++ b/routers/private/actions.go @@ -41,12 +41,9 @@ func GenerateActionsRunnerToken(ctx *context.PrivateContext) { }) } - var token *actions_model.ActionRunnerToken - if genRequest.PutToken == "" { - token, err = actions_model.GetLatestRunnerToken(ctx, owner, repo) - } - if genRequest.PutToken != "" || errors.Is(err, util.ErrNotExist) || (token != nil && !token.IsActive) { - token, err = actions_model.NewRunnerToken(ctx, owner, repo, genRequest.PutToken) + token, err := actions_model.GetLatestRunnerToken(ctx, owner, repo) + if errors.Is(err, util.ErrNotExist) || (token != nil && !token.IsActive) { + token, err = actions_model.NewRunnerToken(ctx, owner, repo, "") if err != nil { errMsg := fmt.Sprintf("error while creating runner token: %v", err) log.Error("NewRunnerToken failed: %v", errMsg)