diff --git a/README.md b/README.md
index ee35009..94e9100 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Matrix Message github action
-This is a simple github action to send messages to matrix servers.
+This is a simple github action to send messages with subjects to matrix servers.
## Usage
@@ -10,8 +10,7 @@ Sending messages requires generating of an access token, which can be done with
The Room ID does not refer to the room's name, but its unique ID. In Riot, this
can be found by navigating to 'Room Settings' -> 'Advanced'.
-`formatted_message` is optional, and accepts Matrix HTML-formatted message. If
-it is not specified, only the `message` argument will be sent.
+Markdown-formatted messages are supported.
```workflow
name: Send a hello world to matrix every 5 minutes
@@ -23,11 +22,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: send message
- uses: s3krit/matrix-message-action@v0.0.1
+ uses: olabiniV2/matrix-message@v0.0.1
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
+ subject: "Something"
message: "Hello, world"
- formatted_message: "Hello
world!"
server: "matrix.org"
```
+
+
+## Credits
+
+This project was primarily created by Martin Pugh (pugh@s3kr.it). This version is a very slight change that might be
+contributed back soon.
diff --git a/action.yml b/action.yml
index dc416c4..a2a842d 100644
--- a/action.yml
+++ b/action.yml
@@ -1,6 +1,6 @@
-name: matrix-message
-description: Send a message to a matrix channel
-author: Martin Pugh (pugh@s3kr.it)
+name: matrix-msg
+description: Send a message with subject to a matrix channel
+author: Ola Bini (ola@olabini.se)
inputs:
server:
description: "Matrix server hostname"
@@ -15,9 +15,13 @@ inputs:
default: ""
required: true
message:
- description: "Message to send in plaintext format"
+ description: "Message to send in markdown or html format"
default: ""
required: true
+ subject:
+ description: "Subject of message in plaintext format"
+ default: ""
+ required: false
runs:
using: docker
image: 'Dockerfile'
diff --git a/entrypoint.sh b/entrypoint.sh
index 8210fa2..4cdcf84 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -2,8 +2,12 @@
# structure_message $content $formatted_content (optional)
structure_message() {
+ subject="$2"
+ if [ -z "$subject" ]; then
+ subject="$1"
+ fi
parsed="$(echo "$1" | markdown)"
- body=$(jq -Rs --arg body "$1" --arg formatted_body "$parsed" '{"msgtype": "m.text", $body, "format": "org.matrix.custom.html", $formatted_body}' < /dev/null)
+ body=$(jq -Rs --arg body "$subject" --arg formatted_body "$parsed" '{"msgtype": "m.text", $body, "format": "org.matrix.custom.html", $formatted_body}' < /dev/null)
echo "$body"
}
@@ -18,5 +22,6 @@ send_message() {
exit 1
fi
}
-echo "$INPUT_MESSAGE"
-send_message "$(structure_message "$INPUT_MESSAGE")" "$INPUT_ROOM_ID" "$INPUT_ACCESS_TOKEN"
+echo "Subject: $INPUT_SUBJECT"
+echo "Message: $INPUT_MESSAGE"
+send_message "$(structure_message "$INPUT_MESSAGE" "$INPUT_SUBJECT")" "$INPUT_ROOM_ID" "$INPUT_ACCESS_TOKEN"