[ci skip] Fix Slack message formatting to use Block Kit mrkdwn
This commit is contained in:
parent
e59928187b
commit
284fee15ca
1 changed files with 16 additions and 5 deletions
|
|
@ -371,12 +371,23 @@ if [[ "$SEND_SLACK" == true ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use python3 to JSON-escape the message body safely
|
# Use python3 to build Slack Block Kit payload with proper mrkdwn
|
||||||
json_payload=$(python3 -c "
|
json_payload=$(printf '%b' "$slack_text" | python3 -c "
|
||||||
import json, sys
|
import json, sys
|
||||||
text = sys.stdin.read()
|
text = sys.stdin.read().strip()
|
||||||
print(json.dumps({'text': text}))
|
payload = {
|
||||||
" <<< "$slack_text")
|
'blocks': [
|
||||||
|
{
|
||||||
|
'type': 'section',
|
||||||
|
'text': {
|
||||||
|
'type': 'mrkdwn',
|
||||||
|
'text': text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
print(json.dumps(payload))
|
||||||
|
")
|
||||||
|
|
||||||
curl -s -X POST "$SLACK_WEBHOOK_URL" \
|
curl -s -X POST "$SLACK_WEBHOOK_URL" \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue