add coda webhook usage;
add apline version to dockerfile;
This commit is contained in:
parent
15cf91aeef
commit
dc6109844f
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:alpine as app-builder
|
||||
FROM golang:1.20-alpine as app-builder
|
||||
WORKDIR $GOPATH/src/ticket-pimp/
|
||||
COPY . .
|
||||
RUN apk add git
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ package controller
|
|||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
d "ticket-pimp/bot/domain"
|
||||
"ticket-pimp/bot/domain"
|
||||
)
|
||||
|
||||
func (wc *WorkflowController) Workflow(name string) (string, error) {
|
||||
coda := wc.iCoda
|
||||
|
||||
yt := wc.iYouTrack
|
||||
|
||||
projectID, err := yt.GetProjectIDByName("APP")
|
||||
|
|
@ -23,30 +25,41 @@ func (wc *WorkflowController) Workflow(name string) (string, error) {
|
|||
|
||||
if issue != nil {
|
||||
var (
|
||||
git, gitBuild *d.Git
|
||||
cloud *d.Folder
|
||||
git, gitBuild *domain.Git
|
||||
cloud *domain.Folder
|
||||
)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(3)
|
||||
|
||||
go func(ref **d.Git) {
|
||||
go func(ref **domain.Git) {
|
||||
defer wg.Done()
|
||||
*ref, _ = wc.CreateRepo(issue.Key)
|
||||
}(&git)
|
||||
|
||||
go func(ref **d.Git) {
|
||||
go func(ref **domain.Git) {
|
||||
defer wg.Done()
|
||||
*ref, _ = wc.CreateRepo(issue.Key + "-build")
|
||||
}(&gitBuild)
|
||||
|
||||
go func(ref **d.Folder) {
|
||||
go func(ref **domain.Folder) {
|
||||
defer wg.Done()
|
||||
*ref, _ = wc.CreateFolder(issue.Key + " - " + issue.Summary)
|
||||
}(&cloud)
|
||||
|
||||
wg.Wait()
|
||||
|
||||
taskDraft := domain.CodaIssue{
|
||||
ID: issue.ID,
|
||||
Summary: name,
|
||||
URL: "",
|
||||
Git: git.HtmlUrl,
|
||||
GitBuild: fmt.Sprintf("ssh://%s/%s.git", gitBuild.SshUrl, gitBuild.FullName),
|
||||
Folder: cloud.PrivateURL,
|
||||
}
|
||||
|
||||
coda.CreateTask(taskDraft)
|
||||
|
||||
yt.UpdateIssue(
|
||||
issue,
|
||||
cloud.PrivateURL,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package domain
|
||||
|
||||
type CodaIssue struct {
|
||||
ID string `json:"id"`
|
||||
Summary string `json:"summary"`
|
||||
URL string `json:"url"`
|
||||
Git string `json:"git"`
|
||||
GitBuild string `json:"git-build"`
|
||||
Folder string `json:"folder"`
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package ext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"ticket-pimp/bot/domain"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -11,13 +13,14 @@ type Coda struct {
|
|||
|
||||
type ICoda interface {
|
||||
ListDocs()
|
||||
CreateTask(task domain.CodaIssue)
|
||||
}
|
||||
|
||||
func NewCodaClient() *Coda {
|
||||
|
||||
client := NewClient().
|
||||
SetTimeout(5 * time.Second).
|
||||
SetCommonBearerAuthToken("f54477f0-98ca-4285-844f-9fa2ef34475d").
|
||||
SetCommonBearerAuthToken("0d5a6853-8bb1-4208-9014-318094f5b21c").
|
||||
SetBaseURL("https://coda.io/apis/v1")
|
||||
|
||||
return &Coda{
|
||||
|
|
@ -47,3 +50,12 @@ func (c *Coda) ListDocs() {
|
|||
log.Print(resp)
|
||||
|
||||
}
|
||||
|
||||
func (c *Coda) CreateTask(task domain.CodaIssue) {
|
||||
resp, _ := c.R().
|
||||
SetBody(task).
|
||||
SetContentType("application/json").
|
||||
Post("/docs/Ic3IZpQ3Wk/hooks/automation/grid-auto-NlUwM7F7Cr")
|
||||
|
||||
fmt.Print(resp)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue