This commit is contained in:
parent
5d0d3eb4bd
commit
8ff3cc5034
1 changed files with 21 additions and 8 deletions
29
main.go
29
main.go
|
|
@ -43,6 +43,7 @@ func main() {
|
|||
u, err := uuid.NewUUID()
|
||||
if err != nil {
|
||||
githubactions.Fatalf("Error generating UUID: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
data.CardID = u.String()
|
||||
data.Add = ""
|
||||
|
|
@ -64,73 +65,85 @@ func main() {
|
|||
project := githubactions.GetInput("project")
|
||||
if project == "" {
|
||||
githubactions.Fatalf("Missing input 'project'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.Project = project
|
||||
|
||||
commit := githubactions.GetInput("commit")
|
||||
if commit == "" {
|
||||
githubactions.Fatalf("Missing input 'commit'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.Commit = commit
|
||||
|
||||
branch := githubactions.GetInput("branch")
|
||||
if branch == "" {
|
||||
githubactions.Fatalf("Missing input 'branch'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.Branch = branch
|
||||
|
||||
status := githubactions.GetInput("status")
|
||||
if status == "" {
|
||||
githubactions.Fatalf("Missing input 'status'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.Status = status
|
||||
|
||||
actionid := githubactions.GetInput("actionid")
|
||||
if actionid == "" {
|
||||
githubactions.Fatalf("Missing input 'actionid'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.ActionID = actionid
|
||||
|
||||
webhook := githubactions.GetInput("webhook")
|
||||
if webhook == "" {
|
||||
githubactions.Fatalf("Missing input 'webshook'")
|
||||
githubactions.Fatalf("Missing input 'webhook'")
|
||||
os.Exit(1)
|
||||
}
|
||||
webhook = fmt.Sprintf("%s&threadKey=%s%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", webhook, data.Commit, data.ActionID)
|
||||
|
||||
giturl := githubactions.GetInput("giturl")
|
||||
if webhook == "" {
|
||||
if giturl == "" {
|
||||
githubactions.Fatalf("Missing input 'giturl'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.GitURL = fmt.Sprintf("%s&threadKey=%s%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", giturl, data.Commit, data.ActionID)
|
||||
data.GitURL = giturl
|
||||
|
||||
body := githubactions.GetInput("event_body")
|
||||
data.EventBody = body
|
||||
|
||||
fmt.Println("URL:> ", webhook)
|
||||
githubactions.Infof("using URL: %s", webhook)
|
||||
// fmt.Println("URL:> ", webhook)
|
||||
|
||||
// var jsonStr = []byte(fmt.Sprintf(data, project, commit, branch, status, actionid))
|
||||
|
||||
jsonStr, err := card(data)
|
||||
if err != nil {
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// log.Printf("retrieved data: %s", string(jsonStr))
|
||||
|
||||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
fmt.Println("response Status:", resp.Status)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
fmt.Printf("response: %+v\n", resp)
|
||||
// fmt.Printf("data: %+v\n", jsonStr)
|
||||
githubactions.Infof("json: %s", jsonStr)
|
||||
githubactions.Fatalf("response: %+v\n", resp)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue