This commit is contained in:
parent
557fde5dff
commit
2a8f2dea76
3 changed files with 15 additions and 2 deletions
2
go.mod
2
go.mod
|
|
@ -6,3 +6,5 @@ require (
|
||||||
github.com/google/go-cmp v0.7.0
|
github.com/google/go-cmp v0.7.0
|
||||||
github.com/sethvargo/go-githubactions v1.3.2
|
github.com/sethvargo/go-githubactions v1.3.2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require github.com/google/uuid v1.6.0 // indirect
|
||||||
|
|
|
||||||
10
main.go
10
main.go
|
|
@ -4,10 +4,12 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/sethvargo/go-githubactions"
|
"github.com/sethvargo/go-githubactions"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -21,6 +23,7 @@ const (
|
||||||
var message string
|
var message string
|
||||||
|
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
|
CardID string
|
||||||
Title string
|
Title string
|
||||||
SubTitle string
|
SubTitle string
|
||||||
Author string
|
Author string
|
||||||
|
|
@ -38,6 +41,11 @@ type templateData struct {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
data := templateData{}
|
data := templateData{}
|
||||||
|
u, err := uuid.NewUUID()
|
||||||
|
if err != nil {
|
||||||
|
githubactions.Fatalf("Error generating UUID: %v", err)
|
||||||
|
}
|
||||||
|
data.CardID = u.String()
|
||||||
data.Add = ""
|
data.Add = ""
|
||||||
|
|
||||||
author := githubactions.GetInput("author")
|
author := githubactions.GetInput("author")
|
||||||
|
|
@ -107,6 +115,8 @@ func main() {
|
||||||
githubactions.Fatalf("error %s", err.Error())
|
githubactions.Fatalf("error %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slog.Info("retrieved data", "data", string(jsonStr))
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
{
|
{
|
||||||
"cardsV2": [
|
"cardsV2": [
|
||||||
{
|
{
|
||||||
"cardId": "notify-{{ .ActionID }}",
|
"cardId": "notify-{{ .CardID }}",
|
||||||
"card": {
|
"card": {
|
||||||
"header": {
|
"header": {
|
||||||
"title": "{{ .Title }}",
|
"title": "{{ .Title }}",
|
||||||
"subtitle": "{{ .SubTitle }}",
|
"subtitle": "{{ .SubTitle }}",
|
||||||
"imageUrl": "{{ .IconUrl }}",
|
"imageUrl": "{{ .IconUrl }}",
|
||||||
"imageType": "SQUARE"
|
"imageType": "SQUARE",
|
||||||
|
"imageAltText": "message avatar image"
|
||||||
},
|
},
|
||||||
"sections": [
|
"sections": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue