package main import ( "bytes" "fmt" "net/http" "github.com/sethvargo/go-githubactions" ) func main() { project := githubactions.GetInput("project") if project == "" { githubactions.Fatalf("Missing input 'project'") } commit := githubactions.GetInput("commit") if commit == "" { githubactions.Fatalf("Missing input 'commit'") } branch := githubactions.GetInput("branch") if branch == "" { githubactions.Fatalf("Missing input 'branch'") } status := githubactions.GetInput("status") if status == "" { githubactions.Fatalf("Missing input 'status'") } actionid := githubactions.GetInput("actionid") if actionid == "" { githubactions.Fatalf("Missing input 'actionid'") } webhook := githubactions.GetInput("webhook") if webhook == "" { githubactions.Fatalf("Missing input 'webshook'") } fmt.Println("URL:> ", webhook) data := `{ "cards": [ { "header": { "title": "GitHub Action", "subtitle": "Build Job", "imageUrl": "https://github.githubassets.com/images/modules/logos_page/Octocat.png", "imageStyle": "IMAGE" }, "sections": [ { "widgets": [ { "textParagraph": { "text": "Project: %s
Commit-id: %s
Branch: %s
Build Status: %s" }, "buttons": [ { "textButton": { "text": "Job Details", "onClick": { "openLink": { "url": "https://github.com/DTherHtun/web-app-flux/runs/%s" } } } } ] } ] } ] } ] }` var jsonStr = []byte(fmt.Sprintf(data, project, commit, branch, status, actionid )) req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr)) if err != nil { panic(err) } req.Header.Set("Content-Type", "application/json; charset=UTF-8") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() fmt.Println("response Status:", resp.Status) }