Skip to content

Commit 35a9664

Browse files
committed
Add parsing of message from markdown to html...
... and remove formatted_message
1 parent ecd689b commit 35a9664

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM parity/tools:latest
2+
RUN apk add markdown
23
COPY entrypoint.sh /
3-
CMD chmod +x /entrypoint.sh
4+
RUN chmod +x /entrypoint.sh
45
ENTRYPOINT /entrypoint.sh

action.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ inputs:
1818
description: "Message to send in plaintext format"
1919
default: ""
2020
required: true
21-
formatted_message:
22-
description: "Message to send, formatted in Matrix HTML"
23-
default: ""
24-
required: false
2521
runs:
2622
using: docker
2723
image: 'Dockerfile'

entrypoint.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
# structure_message $content $formatted_content (optional)
44
structure_message() {
5-
if [ -z "$2" ]; then
6-
body=$(jq -Rs --arg body "$1" '{"msgtype": "m.text", $body}' < /dev/null)
7-
else
8-
body=$(jq -Rs --arg body "$1" --arg formatted_body "$2" '{"msgtype": "m.text", $body, "format": "org.matrix.custom.html", $formatted_body}' < /dev/null)
9-
fi
5+
parsed="$(echo "$1" | markdown)"
6+
body=$(jq -Rs --arg body "$1" --arg formatted_body "$parsed" '{"msgtype": "m.text", $body, "format": "org.matrix.custom.html", $formatted_body}' < /dev/null)
107
echo "$body"
118
}
129

@@ -22,4 +19,4 @@ send_message() {
2219
fi
2320
}
2421

25-
send_message "$(structure_message "$INPUT_MESSAGE" "$INPUT_FORMATTED_MESSAGE")" "$INPUT_ROOM_ID" "$INPUT_ACCESS_TOKEN"
22+
send_message "$(structure_message "$INPUT_MESSAGE")" "$INPUT_ROOM_ID" "$INPUT_ACCESS_TOKEN"

0 commit comments

Comments
 (0)