> ## Content Index
> Fetch the complete content index at: https://www.process-one.net/llms.txt
> Use this file to discover other available public pages before exploring further.

# xmpp-notifer v1.0.0
- URL: https://www.process-one.net/blog/xmpp-notifer-v1-0-0/
- Published: 2020-03-05T17:09:00.000Z
- Updated: 2024-09-16T16:10:52.000Z
- Author: ProcessOne

We just released a new GitHub Action called [xmpp-notifier](https://github.com/marketplace/actions/xmpp-notifier?ref=process-one.net)! It allows sending notifications to XMPP, and uses our [go-xmpp library](https://github.com/FluuxIO/go-xmpp?ref=process-one.net) 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):

```yaml
on:
  [pull_request]

```

Following this, we can add a job that will notify us on test failures. Let’s call it `notif-script`:

```yaml
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.

- [Here’s the GitHub Action xmpp-notifier repository](https://github.com/processone/xmpp-notifier?ref=process-one.net)
- [Learn more about GitHub Actions with the official documentation](https://help.github.com/en/actions?ref=process-one.net)