chore: Add matrix notify workflow

This commit is contained in:
Christian Kußowski 2026-02-28 12:04:30 +01:00
parent 0436f16aa9
commit 13bd504f17
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

49
.github/workflows/matrix_notify.yaml vendored Normal file
View file

@ -0,0 +1,49 @@
name: Matrix Notification
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send notification to Matrix room
env:
HOMESERVER: ${{ secrets.MATRIX_HOMESERVER }}
ACCESS_TOKEN: ${{ secrets.MATRIX_ACCESS_TOKEN }}
ROOM_ID: ${{ secrets.MATRIX_ROOM_ID }}
EVENT_NAME: ${{ github.event_name }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_URL: ${{ github.event.issue.html_url }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
if [ "${EVENT_NAME}" = "issues" ]; then
PREFIX="New issue"
TITLE="${ISSUE_TITLE}"
URL="${ISSUE_URL}"
else
PREFIX="New pull request"
TITLE="${PR_TITLE}"
URL="${PR_URL}"
fi
PLAIN="${PREFIX}: ${TITLE} - ${URL}"
HTML="${PREFIX}: <b>${TITLE}</b> - <a href=\"${URL}\">${URL}</a>"
TXN_ID=$(date +%s%N)
curl -s -o /dev/null -w "%{http_code}" -X PUT \
"${HOMESERVER}/_matrix/client/v3/rooms/${ROOM_ID}/send/m.room.message/${TXN_ID}" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"msgtype": "m.text",
"body": "${PLAIN}",
"format": "org.matrix.custom.html",
"formatted_body": "${HTML}"
}
EOF