feat(github): allow to customize action name
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user