feat(github): allow to customize action name

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-03-12 22:15:52 +01:00
parent c69ee9e5f7
commit 10f7c8ff13
4 changed files with 62 additions and 42 deletions

View File

@@ -10,20 +10,21 @@ import (
)
type GithubIssuesOpener struct {
token, repository, owner string
context context.Context
client *github.Client
token, repository, owner, customActionName string
context context.Context
client *github.Client
}
func NewGithubIssueOpener(ctx context.Context, config map[string]string) *GithubIssuesOpener {
client := github.NewClient(nil).WithAuthToken(config["token"])
return &GithubIssuesOpener{
client: client,
token: config["token"],
repository: config["repository"],
owner: config["owner"],
context: ctx,
client: client,
token: config["token"],
repository: config["repository"],
owner: config["owner"],
customActionName: config["customActionName"],
context: ctx,
}
}
@@ -63,9 +64,13 @@ func (g *GithubIssuesOpener) Run(ctx context.Context, params action.ActionParams
}
func (g *GithubIssuesOpener) Definition() action.ActionDefinition {
actionName := "create_github_issue"
if g.customActionName != "" {
actionName = g.customActionName
}
if g.repository != "" && g.owner != "" {
return action.ActionDefinition{
Name: "create_github_issue",
Name: action.ActionDefinitionName(actionName),
Description: "Create a new issue on a GitHub repository.",
Properties: map[string]jsonschema.Definition{
"text": {
@@ -81,7 +86,7 @@ func (g *GithubIssuesOpener) Definition() action.ActionDefinition {
}
}
return action.ActionDefinition{
Name: "create_github_issue",
Name: action.ActionDefinitionName(actionName),
Description: "Create a new issue on a GitHub repository.",
Properties: map[string]jsonschema.Definition{
"text": {