mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 18:24:14 +01:00
df694f6a7d
Backport #28791 by @yp05327 panic: ![image](https://github.com/go-gitea/gitea/assets/18380374/7fcde2ad-1d42-4b60-b120-3b60a8926e8e) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/49d9f0ca-e590-4a35-8ca2-1317d1b7c939) Co-authored-by: yp05327 <576951401@qq.com>
29 lines
697 B
Go
29 lines
697 B
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package private
|
|
|
|
import (
|
|
"context"
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
)
|
|
|
|
type GenerateTokenRequest struct {
|
|
Scope string
|
|
}
|
|
|
|
// GenerateActionsRunnerToken calls the internal GenerateActionsRunnerToken function
|
|
func GenerateActionsRunnerToken(ctx context.Context, scope string) (string, ResponseExtra) {
|
|
reqURL := setting.LocalURL + "api/internal/actions/generate_actions_runner_token"
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST", GenerateTokenRequest{
|
|
Scope: scope,
|
|
})
|
|
|
|
resp, extra := requestJSONResp(req, &responseText{})
|
|
if resp == nil {
|
|
return "", extra
|
|
}
|
|
return resp.Text, extra
|
|
}
|