feat(github): allow to customize action name
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
@@ -10,19 +10,20 @@ import (
|
||||
)
|
||||
|
||||
type GithubIssuesCloser struct {
|
||||
token, repository, owner string
|
||||
context context.Context
|
||||
client *github.Client
|
||||
token, repository, owner, customActionName string
|
||||
context context.Context
|
||||
client *github.Client
|
||||
}
|
||||
|
||||
func NewGithubIssueCloser(ctx context.Context, config map[string]string) *GithubIssuesCloser {
|
||||
client := github.NewClient(nil).WithAuthToken(config["token"])
|
||||
return &GithubIssuesCloser{
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +78,13 @@ func (g *GithubIssuesCloser) Run(ctx context.Context, params action.ActionParams
|
||||
}
|
||||
|
||||
func (g *GithubIssuesCloser) Definition() action.ActionDefinition {
|
||||
actionName := "close_github_issue"
|
||||
if g.customActionName != "" {
|
||||
actionName = g.customActionName
|
||||
}
|
||||
if g.repository != "" && g.owner != "" {
|
||||
return action.ActionDefinition{
|
||||
Name: "close_github_issue",
|
||||
Name: action.ActionDefinitionName(actionName),
|
||||
Description: "Closes a Github issue.",
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"issue_number": {
|
||||
@@ -92,7 +97,7 @@ func (g *GithubIssuesCloser) Definition() action.ActionDefinition {
|
||||
}
|
||||
|
||||
return action.ActionDefinition{
|
||||
Name: "close_github_issue",
|
||||
Name: action.ActionDefinitionName(actionName),
|
||||
Description: "Closes a Github issue.",
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"repository": {
|
||||
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
)
|
||||
|
||||
type GithubIssuesLabeler struct {
|
||||
token, repository, owner string
|
||||
availableLabels []string
|
||||
context context.Context
|
||||
client *github.Client
|
||||
token, repository, owner, customActionName string
|
||||
availableLabels []string
|
||||
context context.Context
|
||||
client *github.Client
|
||||
}
|
||||
|
||||
func NewGithubIssueLabeler(ctx context.Context, config map[string]string) *GithubIssuesLabeler {
|
||||
@@ -29,12 +29,13 @@ func NewGithubIssueLabeler(ctx context.Context, config map[string]string) *Githu
|
||||
}
|
||||
|
||||
return &GithubIssuesLabeler{
|
||||
client: client,
|
||||
token: config["token"],
|
||||
repository: config["repository"],
|
||||
owner: config["owner"],
|
||||
context: ctx,
|
||||
availableLabels: availableLabels,
|
||||
client: client,
|
||||
token: config["token"],
|
||||
customActionName: config["customActionName"],
|
||||
repository: config["repository"],
|
||||
owner: config["owner"],
|
||||
context: ctx,
|
||||
availableLabels: availableLabels,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,9 +71,13 @@ func (g *GithubIssuesLabeler) Run(ctx context.Context, params action.ActionParam
|
||||
}
|
||||
|
||||
func (g *GithubIssuesLabeler) Definition() action.ActionDefinition {
|
||||
actionName := "add_label_to_github_issue"
|
||||
if g.customActionName != "" {
|
||||
actionName = g.customActionName
|
||||
}
|
||||
if g.repository != "" && g.owner != "" {
|
||||
return action.ActionDefinition{
|
||||
Name: "add_label_to_github_issue",
|
||||
Name: action.ActionDefinitionName(actionName),
|
||||
Description: "Add a label to a Github issue. You might want to assign labels to issues to categorize them.",
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"issue_number": {
|
||||
@@ -89,7 +94,7 @@ func (g *GithubIssuesLabeler) Definition() action.ActionDefinition {
|
||||
}
|
||||
}
|
||||
return action.ActionDefinition{
|
||||
Name: "add_label_to_github_issue",
|
||||
Name: action.ActionDefinitionName(actionName),
|
||||
Description: "Add a label to a Github issue. You might want to assign labels to issues to categorize them.",
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"issue_number": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -11,20 +11,21 @@ import (
|
||||
)
|
||||
|
||||
type GithubIssueSearch struct {
|
||||
token, repository, owner string
|
||||
context context.Context
|
||||
client *github.Client
|
||||
token, repository, owner, customActionName string
|
||||
context context.Context
|
||||
client *github.Client
|
||||
}
|
||||
|
||||
func NewGithubIssueSearch(ctx context.Context, config map[string]string) *GithubIssueSearch {
|
||||
client := github.NewClient(nil).WithAuthToken(config["token"])
|
||||
|
||||
return &GithubIssueSearch{
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,9 +69,13 @@ func (g *GithubIssueSearch) Run(ctx context.Context, params action.ActionParams)
|
||||
}
|
||||
|
||||
func (g *GithubIssueSearch) Definition() action.ActionDefinition {
|
||||
actionName := "search_github_issue"
|
||||
if g.customActionName != "" {
|
||||
actionName = g.customActionName
|
||||
}
|
||||
if g.repository != "" && g.owner != "" {
|
||||
return action.ActionDefinition{
|
||||
Name: "search_github_issue",
|
||||
Name: action.ActionDefinitionName(actionName),
|
||||
Description: "Search between github issues",
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"query": {
|
||||
@@ -82,7 +87,7 @@ func (g *GithubIssueSearch) Definition() action.ActionDefinition {
|
||||
}
|
||||
}
|
||||
return action.ActionDefinition{
|
||||
Name: "search_github_issue",
|
||||
Name: action.ActionDefinitionName(actionName),
|
||||
Description: "Search between github issues",
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"query": {
|
||||
|
||||
Reference in New Issue
Block a user