diff --git a/README.md b/README.md index c04bf87..ae49066 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/main.go b/main.go index 42883e2..e61b603 100644 --- a/main.go +++ b/main.go @@ -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"` @@ -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 @@ -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, @@ -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), diff --git a/message.go b/message.go index 5008c56..7eaa433 100644 --- a/message.go +++ b/message.go @@ -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"` diff --git a/step.yml b/step.yml index 916bd57..4744e5a 100644 --- a/step.yml +++ b/step.yml @@ -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"