CI: migrate push notification to helper script

main
Adriaan de Groot 4 years ago
parent a73ad23b9f
commit e773fb65a8

@ -30,13 +30,12 @@ jobs:
- name: "prepare env"
run: |
sudo apt-get update
sudo apt-get -y install git-core
sudo apt-get -y install git-core jq
sudo apt-get -y install \
build-essential \
cmake \
extra-cmake-modules \
gettext \
jq \
kio-dev \
libatasmart-dev \
libboost-python-dev \
@ -80,17 +79,19 @@ jobs:
run: make install VERBOSE=1
- name: "notify: ok"
if: ${{ success() && github.repository == 'calamares/calamares' }}
env:
MATRIX_TOKEN: ${{ secrets.MATRIX_TOKEN }}
MATRIX_ROOM: ${{ secrets.MATRIX_ROOM }}
run: |
curl -s -XPOST -d '{"msgtype":"m.text", "body":"OK ${{ github.workflow }} in ${{ github.repository }} ${{ github.actor }} on ${{ github.event.ref }}\n.. ${{ steps.pre_build.outputs.message }}"}' 'https://matrix.org/_matrix/client/r0/rooms/%21${{ secrets.MATRIX_ROOM }}/send/m.room.message?access_token=${{ secrets.MATRIX_TOKEN }}' > /dev/null
"$SRCDIR/ci/notify.sh" OK '${{ github.workflow }}' '${{ github.repository }}' '${{ github.actor }}' '${{ github.event.ref }}' \
'${{ steps.pre_build.outputs.message }}' \
''
- name: "notify: fail"
if: ${{ failure() && github.repository == 'calamares/calamares' }}
run: |
curl -s -XPOST -d '{"msgtype":"m.text", "body": "FAIL ${{ github.workflow }} in ${{ github.repository }} ${{ github.actor }} on ${{ github.event.ref }}\n.. ${{ steps.pre_build.outputs.message }}\n.. DIFF ${{ github.event.compare }}" }' 'https://matrix.org/_matrix/client/r0/rooms/%21${{ secrets.MATRIX_ROOM }}/send/m.room.message?access_token=${{ secrets.MATRIX_TOKEN }}' > /dev/null
- name: "notify: check"
env:
MATRIX_TOKEN: ${{ secrets.MATRIX_TOKEN }}
MATRIX_ROOM: ${{ secrets.MATRIX_ROOM }}
run: |
"$SRCDIR/ci/notify.sh" OK '${{ github.workflow }}' '${{ github.repository }}' '${{ github.actor }}' '${{ github.event.ref }}' \
'(test)${{ steps.pre_build.outputs.message }}' \
"$SRCDIR/ci/notify.sh" FAIL '${{ github.workflow }}' '${{ github.repository }}' '${{ github.actor }}' '${{ github.event.ref }}' \
'${{ steps.pre_build.outputs.message }}' \
'${{ github.event.compare }}'

@ -42,14 +42,11 @@ test -z "$EVENT" && { echo "! No event data" ; exit 1 ; }
# It's ok for summary or the compare URL to be empty
url="https://matrix.org/_matrix/client/r0/rooms/%21${MATRIX_ROOM}/send/m.room.message?access_token=${MATRIX_TOKEN}"
status_line="${STATUS} ${WORKFLOW} in ${REPOSITORY} ${ACTOR} on ${EVENT}"
summary_line=""
compare_line=""
test -n "$SUMMARY" && summary_line="\n.. ${SUMMARY}"
test -n "$COMPARE" && compare_line="\n.. DIFF ${COMPARE}"
message_data=$(jq -Rs --arg body "${status_line}${summary_line}${compare_line}" '{"msgtype": "m.text", $body}' < /dev/null)
message_data=$(
{
echo "${STATUS} ${WORKFLOW} in ${REPOSITORY} ${ACTOR} on ${EVENT}"
test -n "$SUMMARY" && echo ".. ${SUMMARY}"
test -n "$COMPARE" && echo ".. DIFF ${COMPARE}"
} | jq -Rs '{"msgtype": "m.text", "body":@text}' )
curl -s -XPOST -d "$message_data" "$url" > /dev/null

Loading…
Cancel
Save