This commit is contained in:
parent
d9828186fd
commit
3d63ed4790
4 changed files with 98 additions and 99 deletions
98
main.go
98
main.go
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue