diff --git a/go.mod b/go.mod index fc33f46..1333d6b 100644 --- a/go.mod +++ b/go.mod @@ -6,3 +6,5 @@ require ( github.com/google/go-cmp v0.7.0 github.com/sethvargo/go-githubactions v1.3.2 ) + +require github.com/google/uuid v1.6.0 // indirect diff --git a/main.go b/main.go index 3f261ce..564fb5e 100644 --- a/main.go +++ b/main.go @@ -4,10 +4,12 @@ import ( "bytes" _ "embed" "fmt" + "log/slog" "net/http" "os" "text/template" + "github.com/google/uuid" "github.com/sethvargo/go-githubactions" ) @@ -21,6 +23,7 @@ const ( var message string type templateData struct { + CardID string Title string SubTitle string Author string @@ -38,6 +41,11 @@ type templateData struct { func main() { data := templateData{} + u, err := uuid.NewUUID() + if err != nil { + githubactions.Fatalf("Error generating UUID: %v", err) + } + data.CardID = u.String() data.Add = "" author := githubactions.GetInput("author") @@ -107,6 +115,8 @@ func main() { githubactions.Fatalf("error %s", err.Error()) } + slog.Info("retrieved data", "data", string(jsonStr)) + req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr)) if err != nil { panic(err) diff --git a/message.tpl b/message.tpl index aab905c..dc9ca5b 100644 --- a/message.tpl +++ b/message.tpl @@ -1,13 +1,14 @@ { "cardsV2": [ { - "cardId": "notify-{{ .ActionID }}", + "cardId": "notify-{{ .CardID }}", "card": { "header": { "title": "{{ .Title }}", "subtitle": "{{ .SubTitle }}", "imageUrl": "{{ .IconUrl }}", - "imageType": "SQUARE" + "imageType": "SQUARE", + "imageAltText": "message avatar image" }, "sections": [ {