Description
I'm trying to send a message by adding a JSON to the markdown block. The JSON itself is a multi-line JSON, but the message arrives as a single-line
What type of issue is this? (place an x in one of the [ ])
Requirements (place an x in each of the [ ])
I have this composite action to send Slack messages:
name: "Slack Notification"
description: "Send Slack notifications for GitHub Actions workflows"
inputs:
slack_bot_token:
description: "Slack bot token"
required: true
channel_id:
description: "Slack channel id"
required: false
default: "channel"
message:
description: "Message to send to Slack"
required: true
blocks:
description: "Optional Slack blocks for advanced message formatting"
required: false
runs:
using: "composite"
steps:
- name: Send Slack notification
uses: slackapi/slack-github-action@v2.0
with:
method: chat.postMessage
token: ${{ inputs.slack_bot_token }}
payload: |
channel: "${{ inputs.channel_id }}"
text: "${{ inputs.message }}"
blocks:
${{ inputs.blocks }}
Which I call in this example workflow:
name: send-slack
on:
workflow_dispatch:
push:
branches:
- main
jobs:
send-slack:
name: send-slack
runs-on: ubuntu-latest
steps:
- name: Create JSON file
run: |
echo '{ "added": [], "removed": [] }' > diff.json
- name: Set output
id: vars
run: |
{
echo 'DIFF_CONTENT<<EOF'
jq '.' diff.json
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: echo (debug)
run: |
echo "${{ steps.vars.outputs.DIFF_CONTENT }}"
- name: Notification
uses: dbeilin/orangutan/composite/send-slack-notification@main
with:
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
channel_id: "@user"
message: "message"
blocks: |
- type: "section"
text:
type: "mrkdwn"
text: '```${{ steps.vars.outputs.DIFF_CONTENT }}```'
My echo step shows a multi-line JSON:

But the message arrives as a single line:

It might be related to quotes, because when I simply copy and pasted the following payload into the block kit playground it seems to work:
{
"blocks": [
{
"type": "section",
"text": {
"text": "```{\n \"added\": [],\n \"removed\": []\n}```",
"type": "mrkdwn"
}
}
]
}

- I tried adding
toJSON() in my markdown block, but it didn't work.
- I tried removing the quotes in the composite:
text: "${{ inputs.message }}", but it didn't work as well.
Feel like any other change I make just breaks the payload.
Any help on this would be appreciated :)
Description
I'm trying to send a message by adding a JSON to the markdown block. The JSON itself is a multi-line JSON, but the message arrives as a single-line
What type of issue is this? (place an
xin one of the[ ])Requirements (place an
xin each of the[ ])I have this composite action to send Slack messages:
Which I call in this example workflow:
My

echostep shows a multi-line JSON:But the message arrives as a single line:

It might be related to quotes, because when I simply copy and pasted the following payload into the block kit playground it seems to work:
toJSON()in my markdown block, but it didn't work.text: "${{ inputs.message }}", but it didn't work as well.Feel like any other change I make just breaks the payload.
Any help on this would be appreciated :)