mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-18 08:08:31 +00:00
[CLI] implement forgejo-cli actions register (squash) no private
Do not go through the private API, directly modify the database (cherry picked from commit1ba7c0d39d
) (cherry picked from commitffe4059b38
)
This commit is contained in:
parent
e7304c0d8e
commit
8a6e6e70ae
4 changed files with 21 additions and 55 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
"code.gitea.io/gitea/modules/private"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
private_routers "code.gitea.io/gitea/routers/private"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -129,10 +130,14 @@ func validateSecret(secret string) error {
|
|||
}
|
||||
|
||||
func RunRegister(ctx context.Context, cliCtx *cli.Context) error {
|
||||
if !ContextGetNoInstallSignals(ctx) {
|
||||
if !ContextGetNoInit(ctx) {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = installSignals(ctx)
|
||||
defer cancel()
|
||||
|
||||
if err := initDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
setting.MustInstalled()
|
||||
|
||||
|
@ -165,12 +170,17 @@ func RunRegister(ctx context.Context, cliCtx *cli.Context) error {
|
|||
// the internal naming. It is still confusing to the developer but
|
||||
// not to the user.
|
||||
//
|
||||
respText, extra := private.ActionsRunnerRegister(ctx, secret, scope, strings.Split(labels, ","), name, version)
|
||||
if extra.HasError() {
|
||||
return handleCliResponseExtra(ctx, extra)
|
||||
owner, repo, err := private_routers.ParseScope(ctx, scope)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := fmt.Fprintf(ContextGetStdout(ctx), "%s", respText); err != nil {
|
||||
runner, err := actions_model.RegisterRunner(ctx, owner, repo, secret, strings.Split(labels, ","), name, version)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while registering runner: %v", err)
|
||||
}
|
||||
|
||||
if _, err := fmt.Fprintf(ContextGetStdout(ctx), "%s", runner.UUID); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue