2023-04-17 11:07:13 -06:00
|
|
|
// 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{})
|
2024-01-15 05:13:35 -07:00
|
|
|
if extra.HasError() {
|
2024-01-15 01:05:30 -07:00
|
|
|
return "", extra
|
|
|
|
}
|
2023-04-17 11:07:13 -06:00
|
|
|
return resp.Text, extra
|
|
|
|
}
|