From 999338848dcb8b5b6691835c994866d8863915d7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 17 Dec 2024 23:49:42 -0800 Subject: [PATCH] Revert wrong change --- cmd/actions.go | 4 ++-- modules/private/actions.go | 3 +-- routers/private/actions.go | 9 +++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cmd/actions.go b/cmd/actions.go index 5b1f427cf9..e0742f6e7e 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 09135eb543..0f144170b1 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 8424c610d5..a3646e1340 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)