chore: test old
All checks were successful
Sample Testing / my_job (push) Successful in 1m52s

This commit is contained in:
Marcel S. Henselin 2026-04-16 11:55:54 +02:00
parent d9828186fd
commit 3d63ed4790
4 changed files with 98 additions and 99 deletions

98
main.go
View file

@ -2,6 +2,7 @@ package main
import (
"bytes"
_ "embed"
"fmt"
"net/http"
"os"
@ -16,6 +17,9 @@ const (
failedColor = "8b0000/dc143c"
)
//go:embed message_old.tpl
var message string
type templateData struct {
Title string
SubTitle string
@ -139,43 +143,6 @@ func card(d templateData) ([]byte, error) {
d.EventBody = "<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>"
}
// tpl := `
//{
// "cards": [
// {
// "header": {
// "title": "{{ .Title }}",
// "subtitle": "{{ .SubTitle }}",
// "imageUrl": "{{ .IconUrl }}",
// "imageStyle": "IMAGE"
// },
// "sections": [
// {
// "widgets": [
// {
// "textParagraph": {
// "text": "<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>"
// },
// "buttons": [
// {
// "textButton": {
// "text": "Job Details",
// "onClick": {
// "openLink": {
// "url": "{{ .GitURL }}/{{ .Project }}/actions/runs/{{ .ActionID }}"
// }
// }
// }
// }
// ]
// }
// ]
// }
// ]
// }
// ]
//}`
if d.Status == "success" {
d.Add = `
{
@ -204,62 +171,7 @@ func card(d templateData) ([]byte, error) {
},`
}
tpl := `
{
"cardsV2": [
{
"cardId": "notify-{{ .ActionID }}",
"card": {
"header": {
"title": "{{ .Title }}",
"subtitle": "{{ .SubTitle }}",
"imageUrl": "{{ .IconUrl }}",
"imageType": "SQUARE"
},
"sections": [
{
"header": "{{ .Title }}",
"collapsible": false,
"widgets": [
{{ .Add }}
{
"decoratedText": {
"startIcon": {
"knownIcon": "PERSON"
},
"text": "<b>{{ .Author }}</b>"
}
},
{
"textParagraph": {
"text": "{{ .EventBody }}",
"maxLines": 2
}
},
{
"buttonList": {
"buttons": [
{
"text": "View Source Event",
"type": "FILLED",
"onClick": {
"openLink": {
"url": "{{ .GitURL }}/{{ .Project }}/actions/runs/{{ .ActionID }}"
}
}
}
]
}
}
]
}
]
}
}
]
}
`
tmpl, err := template.New("").Parse(tpl)
tmpl, err := template.New("message").Parse(message)
if err != nil {
return nil, err
}

View file

@ -50,7 +50,8 @@ func Test_card(t *testing.T) {
"sections": [
{
"header": "test",
"collapsible": false,
"collapsible": true,
"uncollapsibleWidgetsCount": 2,
"widgets": [
{
@ -76,11 +77,7 @@ func Test_card(t *testing.T) {
"text": "no body",
"maxLines": 2
}
}
]
},
{
"widgets": [
},
{
"buttonList": {
"buttons": [

55
message.tpl Normal file
View file

@ -0,0 +1,55 @@
{
"cardsV2": [
{
"cardId": "notify-{{ .ActionID }}",
"card": {
"header": {
"title": "{{ .Title }}",
"subtitle": "{{ .SubTitle }}",
"imageUrl": "{{ .IconUrl }}",
"imageType": "SQUARE"
},
"sections": [
{
"header": "{{ .Title }}",
"collapsible": true,
"uncollapsibleWidgetsCount": 2,
"widgets": [
{{ .Add }}
{
"decoratedText": {
"startIcon": {
"knownIcon": "PERSON"
},
"text": "<b>{{ .Author }}</b>"
}
},
{
"textParagraph": {
"text": "{{ .EventBody }}",
"maxLines": 2
}
},
{
"buttonList": {
"buttons": [
{
"text": "View Source Event",
"type": "FILLED",
"onClick": {
"openLink": {
"url": "{{ .GitURL }}/{{ .Project }}/actions/runs/{{ .ActionID }}"
}
}
}
]
}
}
]
}
]
}
}
]
}

35
message_old.tpl Normal file
View file

@ -0,0 +1,35 @@
{
"cards": [
{
"header": {
"title": "{{ .Title }}",
"subtitle": "{{ .SubTitle }}",
"imageUrl": "{{ .IconUrl }}",
"imageStyle": "IMAGE"
},
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": "<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>"
},
"buttons": [
{
"textButton": {
"text": "Job Details",
"onClick": {
"openLink": {
"url": "{{ .GitURL }}/{{ .Project }}/actions/runs/{{ .ActionID }}"
}
}
}
}
]
}
]
}
]
}
]
}