xmpp-notifer v1.0.0
We just released a new GitHub Action called xmpp-notifier! It allows sending notifications to XMPP, and uses our go-xmpp library under the hood.
Let’s go through an example showing how to use it.
Small example
Say we want to get notifications when tests fail on a pull-request for our Go project. In the /.github/workflows/
directory of our project, we may setup actions as YAML configuration files. Let’s make a file, call it for example xmpp_notif.yaml
, and add the following contents to it.
First add the event we want to trigger the jobs on (as an array):
on:
[pull_request]
Following this, we can add a job that will notify us on test failures. Let’s call it notif-script
:
jobs:
notif-script:
runs-on: ubuntu-latest
name: job that pushes test failures to xmpp
steps:
- name: Run tests
run: |
go test ./... -v -race
# Now lets write the notification action
- name: Tests failed notif
# If the previous step fails, start this one. Otherwise, skip it.
if: failure()
id: test_fail_notif
# Use the xmpp-notifier action
uses: processone/xmpp-notifier@master
# Set the secrets as inputs
with:
# Login expects the bot's bare jid (user@domain)
jid: ${{ secrets.jid }}
# The bot's password
password: ${{ secrets.password }}
# The server we wish to connect to.
server_host: ${{ secrets.server_host }}
# Intended recipient of the notification. Can be a user or room. Bare jid expected.
recipient: ${{ secrets.recipient }}
# Port is optional. Defaults to 5222
server_port: ${{ secrets.server_port }}
# This message will be sent as a <message> payload to the recipient.
# It contains a link to the Pull Request page that triggered the action.
# Test logs are only one click away.
message: |
tests for the following PR have failed : ${{ github.event.pull_request.html_url }}
# Boolean to indicate if correspondent should be treated as a room (true) or a single user (false)
recipient_is_room: true
That’s it! Now if tests fail on a pull request to any branch of our project, we will get notified through XMPP.