DEV Community

Jorge Alberto Díaz Orozco (Akiel)
Jorge Alberto Díaz Orozco (Akiel)

Posted on

A GitHub action to push messages to Rocket.Chat using credentials instead of webhooks

My Workflow

So I found out about #ActionsHackathon thanks to a coworker ;-) and I like hackathons and stickers. I have been playing with GitHub actions during the last weeks and I was intrigued about how all of it works. I have worked with Travis, Bamboo, Gitlab-ci. It does not feel like any of them. That's why I decided to go with building an action myself.

I selected a problem I like and that I have talked about before here and started playing around. I love Rocket.Chat and I love chat notifications and the fact that you can notify a lot of people with a single message if your build breaks or if a new version of your application was deployed for testing is very convenient. Rocket.Chat allows you to add integrations and push messages using webhooks and they actually have a very nice GitHub action to do so. But what if you can't create integrations on this server because you don't have enough privileges? I wanted to be able to do it with only credentials, the URL for the Rocket.Chat server and the name of the channel where I want to post messages.

First, I'm not comfortable with using javascript or typescript and most of the actions I found were written using either of them. I was very happy when I discovered you can just use Docker https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions

I started a new repository and begun writing with the code on the tutorial. Since I created a private repository I could only test the action on itself, so I started a disposable branch on GitHub, created a pull request to use my action, and started playing with different configurations from the same GitHub interface. I would commit the changes to the action on the master branch and then test from the disposable branch.

After a couple of hours, I had written and tested my new action and published it to the marketplace here.

It was fun working on it and the documentation was easy to follow. Now it's time to start actually using it on a project, showing it around and improving it :-)

Submission Category:

DIY Deployments

Yaml File or Link to Code

https://github.com/jadolg/rocketchat-notification-action

Additional Resources / Info

Open source projects involved:

Top comments (0)