forked from opencast/opencast
-
Notifications
You must be signed in to change notification settings - Fork 0
27 lines (26 loc) · 1.43 KB
/
update-matrix-room.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
on:
push:
tags:
- '*.*'
name: Update Matrix Room Description
jobs:
build:
name: Update Matrix Room
runs-on: ubuntu-latest
steps:
- name: update room description
env:
MATRIX_PASS: ${{ secrets.MATRIX_BOT_PASS }}
MATRIX_USER: ${{ secrets.MATRIX_BOT_USER }}
URL_LOGIN: 'https://matrix.org/_matrix/client/r0/login'
URL_LOGOUT: 'https://matrix.org/_matrix/client/r0/logout'
URL_TOPIC: 'https://matrix-client.matrix.org/_matrix/client/r0/rooms/!HBsLKoOIEEOkxAeQvC%3Amatrix.org/state/m.room.topic/'
run: |
TAGS="$(curl https://api.github.com/repos/opencast/opencast/tags | jq -r '.[].name')"
MAJOR="$(echo "$TAGS" | sed 's/\..*$//' | sort --version-sort | tail -n1)"
STABLE="$(echo "$TAGS" | sort --version-sort | tail -n1)"
LEGACY="$(echo "$TAGS" | grep -v "^${MAJOR}" | sort --version-sort | tail -n1)"
TOPIC='{"topic":"opencast.org\n–\nLatest releases: '"$STABLE, $LEGACY"'\n–\nJoin the technical meeting: Tuesday, 3:15 pm UTC at meet.opencast.video (p: welcome)"}'
TOKEN="$(curl -s -XPOST -d '{"type":"m.login.password", "user":"'"$MATRIX_USER"'", "password":"'"$MATRIX_PASS"'", "initial_device_display_name":"GitHub Actions"}' "$URL_LOGIN" | jq -r .access_token)"
curl -s -XPUT -d "${TOPIC}" "${URL_TOPIC}?access_token=${TOKEN}"
curl -s -XPOST "${URL_LOGOUT}?access_token=${TOKEN}"