Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ steps:
- emoji: ":bitrise:"
```

#### Using Block Kit

Please check the format guideline [https://api.slack.com/methods/chat.postMessage#arg_blocks](https://api.slack.com/methods/chat.postMessage#arg_blocks)

```yaml
steps:
- slack:
title: Notify team
inputs:
- workspace_slack_integration_id: example
- message: This is a test notification, please ignore
- blocks: |-
[
{
"type": "section",
"text": {
"type": "plain_text",
"text": "Hello world"
}
}
]

```

## ⚙️ Configuration

Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Input struct {
Channel string `env:"channel"`
ChannelOnError string `env:"channel_on_error"`
Text string `env:"text"`
Blocks string `env:"blocks"`
TextOnError string `env:"text_on_error"`
IconEmoji string `env:"emoji"`
IconEmojiOnError string `env:"emoji_on_error"`
Expand Down Expand Up @@ -93,6 +94,9 @@ type config struct {
ReplyBroadcast bool
LinkNames bool `env:"link_names,opt[yes,no]"`

// Blocks
Blocks string

// Attachment
Color string
PreText string
Expand Down Expand Up @@ -121,6 +125,7 @@ func newMessage(c config) Message {
msg := Message{
Channel: strings.TrimSpace(c.Channel),
Text: c.Text,
Blocks: c.Blocks,
Attachments: []Attachment{{
Fallback: ensureNewlines(c.Message),
Color: c.Color,
Expand Down Expand Up @@ -297,6 +302,7 @@ func parseInputIntoConfig(inp *Input) (config, error) {
WebhookURL: webhookURL,
Channel: selectValue(inp.Channel, inp.ChannelOnError),
Text: selectValue(inp.Text, inp.TextOnError),
Blocks: inp.Blocks,
IconEmoji: selectValue(inp.IconEmoji, inp.IconEmojiOnError),
IconURL: selectValue(inp.IconURL, inp.IconURLOnError),
Username: selectValue(inp.Username, inp.UsernameOnError),
Expand Down
3 changes: 3 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type Message struct {
// Text of the message to send. Required, unless providing only attachments instead.
Text string `json:"text,omitempty"`

// Block Kit payload to send.
Blocks string `json:"blocks,omitempty"`

// Attachments is a list of structured attachments.
Attachments []Attachment `json:"attachments,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ inputs:
description: |
Text of the message to send.
Required unless you wish to send attachments only.
- blocks:
opts:
title: "Block Kit payload"
description: |
Payload of Block Kit to send. Please check the format guideline [https://api.slack.com/methods/chat.postMessage#arg_blocks](https://api.slack.com/methods/chat.postMessage#arg_blocks)
- text_on_error:
opts:
title: "Text of the message if the build failed"
Expand Down