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 {
|
type GithubIssuesCloser struct {
|
||||||
token, repository, owner string
|
token, repository, owner, customActionName string
|
||||||
context context.Context
|
context context.Context
|
||||||
client *github.Client
|
client *github.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGithubIssueCloser(ctx context.Context, config map[string]string) *GithubIssuesCloser {
|
func NewGithubIssueCloser(ctx context.Context, config map[string]string) *GithubIssuesCloser {
|
||||||
client := github.NewClient(nil).WithAuthToken(config["token"])
|
client := github.NewClient(nil).WithAuthToken(config["token"])
|
||||||
return &GithubIssuesCloser{
|
return &GithubIssuesCloser{
|
||||||
client: client,
|
client: client,
|
||||||
token: config["token"],
|
token: config["token"],
|
||||||
repository: config["repository"],
|
repository: config["repository"],
|
||||||
owner: config["owner"],
|
owner: config["owner"],
|
||||||
context: ctx,
|
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 {
|
func (g *GithubIssuesCloser) Definition() action.ActionDefinition {
|
||||||
|
actionName := "close_github_issue"
|
||||||
|
if g.customActionName != "" {
|
||||||
|
actionName = g.customActionName
|
||||||
|
}
|
||||||
if g.repository != "" && g.owner != "" {
|
if g.repository != "" && g.owner != "" {
|
||||||
return action.ActionDefinition{
|
return action.ActionDefinition{
|
||||||
Name: "close_github_issue",
|
Name: action.ActionDefinitionName(actionName),
|
||||||
Description: "Closes a Github issue.",
|
Description: "Closes a Github issue.",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"issue_number": {
|
"issue_number": {
|
||||||
@@ -92,7 +97,7 @@ func (g *GithubIssuesCloser) Definition() action.ActionDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return action.ActionDefinition{
|
return action.ActionDefinition{
|
||||||
Name: "close_github_issue",
|
Name: action.ActionDefinitionName(actionName),
|
||||||
Description: "Closes a Github issue.",
|
Description: "Closes a Github issue.",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GithubIssuesLabeler struct {
|
type GithubIssuesLabeler struct {
|
||||||
token, repository, owner string
|
token, repository, owner, customActionName string
|
||||||
availableLabels []string
|
availableLabels []string
|
||||||
context context.Context
|
context context.Context
|
||||||
client *github.Client
|
client *github.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGithubIssueLabeler(ctx context.Context, config map[string]string) *GithubIssuesLabeler {
|
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{
|
return &GithubIssuesLabeler{
|
||||||
client: client,
|
client: client,
|
||||||
token: config["token"],
|
token: config["token"],
|
||||||
repository: config["repository"],
|
customActionName: config["customActionName"],
|
||||||
owner: config["owner"],
|
repository: config["repository"],
|
||||||
context: ctx,
|
owner: config["owner"],
|
||||||
availableLabels: availableLabels,
|
context: ctx,
|
||||||
|
availableLabels: availableLabels,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,9 +71,13 @@ func (g *GithubIssuesLabeler) Run(ctx context.Context, params action.ActionParam
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GithubIssuesLabeler) Definition() action.ActionDefinition {
|
func (g *GithubIssuesLabeler) Definition() action.ActionDefinition {
|
||||||
|
actionName := "add_label_to_github_issue"
|
||||||
|
if g.customActionName != "" {
|
||||||
|
actionName = g.customActionName
|
||||||
|
}
|
||||||
if g.repository != "" && g.owner != "" {
|
if g.repository != "" && g.owner != "" {
|
||||||
return 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.",
|
Description: "Add a label to a Github issue. You might want to assign labels to issues to categorize them.",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"issue_number": {
|
"issue_number": {
|
||||||
@@ -89,7 +94,7 @@ func (g *GithubIssuesLabeler) Definition() action.ActionDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 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.",
|
Description: "Add a label to a Github issue. You might want to assign labels to issues to categorize them.",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"issue_number": {
|
"issue_number": {
|
||||||
|
|||||||
@@ -10,20 +10,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GithubIssuesOpener struct {
|
type GithubIssuesOpener struct {
|
||||||
token, repository, owner string
|
token, repository, owner, customActionName string
|
||||||
context context.Context
|
context context.Context
|
||||||
client *github.Client
|
client *github.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGithubIssueOpener(ctx context.Context, config map[string]string) *GithubIssuesOpener {
|
func NewGithubIssueOpener(ctx context.Context, config map[string]string) *GithubIssuesOpener {
|
||||||
client := github.NewClient(nil).WithAuthToken(config["token"])
|
client := github.NewClient(nil).WithAuthToken(config["token"])
|
||||||
|
|
||||||
return &GithubIssuesOpener{
|
return &GithubIssuesOpener{
|
||||||
client: client,
|
client: client,
|
||||||
token: config["token"],
|
token: config["token"],
|
||||||
repository: config["repository"],
|
repository: config["repository"],
|
||||||
owner: config["owner"],
|
owner: config["owner"],
|
||||||
context: ctx,
|
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 {
|
func (g *GithubIssuesOpener) Definition() action.ActionDefinition {
|
||||||
|
actionName := "create_github_issue"
|
||||||
|
if g.customActionName != "" {
|
||||||
|
actionName = g.customActionName
|
||||||
|
}
|
||||||
if g.repository != "" && g.owner != "" {
|
if g.repository != "" && g.owner != "" {
|
||||||
return action.ActionDefinition{
|
return action.ActionDefinition{
|
||||||
Name: "create_github_issue",
|
Name: action.ActionDefinitionName(actionName),
|
||||||
Description: "Create a new issue on a GitHub repository.",
|
Description: "Create a new issue on a GitHub repository.",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"text": {
|
"text": {
|
||||||
@@ -81,7 +86,7 @@ func (g *GithubIssuesOpener) Definition() action.ActionDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return action.ActionDefinition{
|
return action.ActionDefinition{
|
||||||
Name: "create_github_issue",
|
Name: action.ActionDefinitionName(actionName),
|
||||||
Description: "Create a new issue on a GitHub repository.",
|
Description: "Create a new issue on a GitHub repository.",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"text": {
|
"text": {
|
||||||
|
|||||||
@@ -11,20 +11,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GithubIssueSearch struct {
|
type GithubIssueSearch struct {
|
||||||
token, repository, owner string
|
token, repository, owner, customActionName string
|
||||||
context context.Context
|
context context.Context
|
||||||
client *github.Client
|
client *github.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGithubIssueSearch(ctx context.Context, config map[string]string) *GithubIssueSearch {
|
func NewGithubIssueSearch(ctx context.Context, config map[string]string) *GithubIssueSearch {
|
||||||
client := github.NewClient(nil).WithAuthToken(config["token"])
|
client := github.NewClient(nil).WithAuthToken(config["token"])
|
||||||
|
|
||||||
return &GithubIssueSearch{
|
return &GithubIssueSearch{
|
||||||
client: client,
|
client: client,
|
||||||
token: config["token"],
|
token: config["token"],
|
||||||
repository: config["repository"],
|
repository: config["repository"],
|
||||||
owner: config["owner"],
|
owner: config["owner"],
|
||||||
context: ctx,
|
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 {
|
func (g *GithubIssueSearch) Definition() action.ActionDefinition {
|
||||||
|
actionName := "search_github_issue"
|
||||||
|
if g.customActionName != "" {
|
||||||
|
actionName = g.customActionName
|
||||||
|
}
|
||||||
if g.repository != "" && g.owner != "" {
|
if g.repository != "" && g.owner != "" {
|
||||||
return action.ActionDefinition{
|
return action.ActionDefinition{
|
||||||
Name: "search_github_issue",
|
Name: action.ActionDefinitionName(actionName),
|
||||||
Description: "Search between github issues",
|
Description: "Search between github issues",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"query": {
|
"query": {
|
||||||
@@ -82,7 +87,7 @@ func (g *GithubIssueSearch) Definition() action.ActionDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return action.ActionDefinition{
|
return action.ActionDefinition{
|
||||||
Name: "search_github_issue",
|
Name: action.ActionDefinitionName(actionName),
|
||||||
Description: "Search between github issues",
|
Description: "Search between github issues",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"query": {
|
"query": {
|
||||||
|
|||||||
Reference in New Issue
Block a user