Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions reaction/githubCreatePr.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ import (
func CreateGihubPr(config map[string]any) error {
ctx := context.Background()

reactionID, githubToken, err := GetGoogleToken(ctx, config)
reactionID, githubToken, err := GetGithubToken(ctx, config)
if err != nil {
return fmt.Errorf("error getting Google token: %w", err)
return fmt.Errorf("error getting Github token: %w", err)
}

if githubToken == "" {
return fmt.Errorf("empty Google token")
return fmt.Errorf("empty Github token")
}

if err != nil {
log.Printf("Failed to get reactions: %v", err)
}
log.Printf("Execute Gmail send email")
return execCreatePr(githubToken, reactionID, config, ctx)
}

Expand Down
49 changes: 49 additions & 0 deletions reaction/githubCreateRepo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package reaction

import (
"context"
"fmt"
"log"

"github.com/google/go-github/v79/github"
)

func CreateGihubTeam(config map[string]any) error {
ctx := context.Background()

reactionID, githubToken, err := GetGithubToken(ctx, config)
if err != nil {
return fmt.Errorf("error getting Github token: %w", err)
}

if githubToken == "" {
return fmt.Errorf("empty Github token")
}

if err != nil {
log.Printf("Failed to get reactions: %v", err)
}
return execCreateGithubTeam(githubToken, reactionID, config, ctx)
}

func execCreateGithubTeam(token string, reactionID string, config map[string]any, ctx context.Context) error {
client := github.NewClient(nil).WithAuthToken(token)

org := "ValianceTekProject"
newRepo := &github.NewTeam{
Name: "New Area Team",
}

_, resp, err := client.Teams.CreateTeam(ctx, org, *newRepo)
if err != nil {
fmt.Printf("Failed to create team: %v\n", err)
if resp != nil {
fmt.Printf("Response Status: %s\n", resp.Status)
}
return err
}

log.Printf("Team created")
return nil
}

20 changes: 20 additions & 0 deletions templates/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ var Services = map[string]*Service{
},
Handler: reaction.CreateGihubPr,
},
"github_create_team": {
Name: "github_create_team",
Description: "Create Test ValianceTekProject orga",
Service: "Github",
Config: []ReactionField{
{
Name: "channel_id",
Type: "text",
Label: "Channel ID",
Required: true,
},
{
Name: "content",
Type: "text",
Label: "Message Content",
Required: true,
},
},
Handler: reaction.CreateGihubTeam,
},
},
},

Expand Down