(p *api.ReleasePayload)
| 242 | } |
| 243 | |
| 244 | func getDingtalkReleasePayload(p *api.ReleasePayload) *DingtalkPayload { |
| 245 | releaseURL := p.Repository.HTMLURL + "/src/" + p.Release.TagName |
| 246 | |
| 247 | author := p.Release.Author.FullName |
| 248 | if author == "" { |
| 249 | author = p.Release.Author.UserName |
| 250 | } |
| 251 | |
| 252 | actionCard := NewDingtalkActionCard("View Release", releaseURL) |
| 253 | actionCard.Text += "# New Release Published" |
| 254 | actionCard.Text += "\n- Repo: " + MarkdownLinkFormatter(p.Repository.HTMLURL, p.Repository.Name) |
| 255 | actionCard.Text += "\n- Tag: " + MarkdownLinkFormatter(releaseURL, p.Release.TagName) |
| 256 | actionCard.Text += "\n- Author: " + author |
| 257 | actionCard.Text += fmt.Sprintf("\n- Draft?: %t", p.Release.Draft) |
| 258 | actionCard.Text += fmt.Sprintf("\n- Pre Release?: %t", p.Release.Prerelease) |
| 259 | actionCard.Text += "\n- Title: " + p.Release.Name |
| 260 | |
| 261 | if p.Release.Body != "" { |
| 262 | actionCard.Text += "\n- Note: " + p.Release.Body |
| 263 | } |
| 264 | |
| 265 | return &DingtalkPayload{ |
| 266 | MsgType: "actionCard", |
| 267 | ActionCard: actionCard, |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | // MarkdownLinkFormatter formats link address and title into Markdown style. |
| 272 | func MarkdownLinkFormatter(link, text string) string { |
no test coverage detected