diff --git a/.github/actions/notify-push/action.yml b/.github/actions/notify-push/action.yml new file mode 100644 index 000000000..9492fa325 --- /dev/null +++ b/.github/actions/notify-push/action.yml @@ -0,0 +1,20 @@ +name: 'Notify on Push' +description: 'Notify Matrix room' + +inputs: + room: + description: 'Matrix Room ID' + required: true + token: + description: 'Matrix Token' + required: true + message: + description: 'Message to send' + required: true + +runs: + using: "composite" + steps: + - shell: bash + run: | + curl -s -XPOST -d $( echo "$INPUT_MESSAGE" | jq -Rs '{"msgtype": "m.text", "body":@text}' ) "https://matrix.org/_matrix/client/r0/rooms/%21${INPUT_ROOM}/send/m.room.message?access_token=${INPUT_TOKEN}" > /dev/null diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b5583c1d3..4ab250158 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -79,19 +79,20 @@ 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: | - "$SRCDIR/ci/notify.sh" OK '${{ github.workflow }}' '${{ github.repository }}' '${{ github.actor }}' '${{ github.event.ref }}' \ - '${{ steps.pre_build.outputs.message }}' \ - '' + uses: ./.github/actions/notify-push + with: + TOKEN: ${{ secrets.MATRIX_TOKEN }} + ROOM: ${{ secrets.MATRIX_ROOM }} + MESSAGE: | + OK ${{ github.workflow }} in ${{ github.repository }} by ${{ github.actor }} on ${{ github.event.ref }} + .. ${{ steps.pre_build.outputs.message }} - name: "notify: fail" if: ${{ failure() && github.repository == 'calamares/calamares' }} - env: - MATRIX_TOKEN: ${{ secrets.MATRIX_TOKEN }} - MATRIX_ROOM: ${{ secrets.MATRIX_ROOM }} - run: | - "$SRCDIR/ci/notify.sh" FAIL '${{ github.workflow }}' '${{ github.repository }}' '${{ github.actor }}' '${{ github.event.ref }}' \ - '${{ steps.pre_build.outputs.message }}' \ - '${{ github.event.compare }}' + uses: ./.github/actions/notify-push + with: + TOKEN: ${{ secrets.MATRIX_TOKEN }} + ROOM: ${{ secrets.MATRIX_ROOM }} + MESSAGE: | + FAIL ${{ github.workflow }} in ${{ github.repository }} by ${{ github.actor }} on ${{ github.event.ref }} + .. ${{ steps.pre_build.outputs.message }} + .. ${{ github.event.compare }}