Python script to send notifications to a matrix room.
|
|
||
|---|---|---|
| .meta | ||
| .gitignore | ||
| Containerfile | ||
| LICENSE | ||
| matrix_notifier.py | ||
| README.md | ||
| requirements.txt | ||
matrix-notifier
Python script to send notifications to a matrix room.
Testing
To test this project you will need:
- The id of a user on a matrix server (referred hereafter as
<user_id>) - A token corresponding to that user (referred hereafter as
<matrix_token>) - The url of the matrix server (referred hereafter as
<server_url>) - The id of the room on which to send the message (referred hereafter as
<room_id>)
All commands are expected to be ran from the root directory of this project.
First build the Docker image with
docker build -t matrix-notifier:latest -f ./Containerfile .
Then send a test message with:
docker run --rm -e MATRIX_TOKEN="<matrix_token>"" matrix-notifier:latest send <server_url> <user_id> <room_id> "This is a test" "<h1>This is a test</h1>"
For example with bogus values:
docker run --rm -e MATRIX_TOKEN="syt_oyEt6NzA2Waer3EF8s5vWbrRBEt88JMS_icF5ZU" matrix-notifier:latest send https://mydomain.tld botuser !tfdBxJRkuvdqD3K7Ma:mydomain.tld "This is a test" "<h1>This is a test</h1>"
Woodpecker integration
In your Woodpecker pipeline, you can integrate the following step:
- name: Notification
image: registry.bobbyblues.com/matrix-notifier:1.0.0
environment:
MATRIX_TOKEN:
from_secret: matrix_token
commands:
- python /app/matrix_notifier.py
send
https://domain.tld
botuser
!tfdBxJRkuvdqD3K7Ma:mydomain.tld
"[CI] ⚠️ Step failed for your project."
"[CI] ⚠️ Step failed for <a href='$CI_PIPELINE_URL'>your</a> project."
when:
- status: [failure]
And define the matrix_token secret, containing a valid matrix token for botuser.