ManoManoTech / homer

Homer is a Slack bot intended to help you to easily share and follow Gitlab merge requests.
MIT License
29 stars 8 forks source link
gitlab slack slack-bot slackbot

CI badge

Homer

Homer

Homer is a Slack bot intended to help you to easily share and follow Gitlab merge requests.

Why Homer?

At ManoMano, we were a bit tired of reading Gitlab emails to try keeping up to date with merge request updates.

Since we use Slack, we decided to create a bot that would help us to share our merge requests to other developers and to track their progress, so we could merge them more quickly:

Slack message

How does it work?

Homer communicates with both Slack and Gitlab to get merge request information and publish Slack messages.

Architecture Architecture

Usage

Commands

Here are the available commands:

Command Description
/homer changelog Display changelogs, for any Gitlab project, between 2 release tags.
/homer project add <project_name\|project_id> Add a Gitlab project to a channel.
/homer project list List the Gitlab projects added to a channel.
/homer project remove Remove a Gitlab project from a channel.
/homer release Create a release for configured Gitlab project in a channel.
/homer review <search> Share a merge request on a channel.
Searches in title and description by default.
Accepts merge request URLs and merge request IDs prefixed with "!".
/homer review list List ongoing reviews shared in a channel.

Share a merge request using Homer

To share a merge request in a Slack channel using Homer, you have to follow the following steps:

1. Make Homer notified of changes happening in the Gitlab project

To keep up to date the Slack messages it creates, Homer needs to be notified when something occurs on the related merge requests.

To do so, you need to set up a webhook in the Gitlab project of your merge request:

2. Add the Gitlab project to a Slack channel

If it is the first time that you share a merge request of the Gitlab project in a Slack channel, you have to link them.

Inside the Slack channel, run one of the following commands:

[!WARNING] If you want to use Homer in a private channel, you need to invite it to the channel first.

3. Share the merge request

To share a Gitlab merge request to a Slack channel, use the /homer review <search> command.

You can provide a merge request ID prefixed with !, e.g.: /homer review !128.

If you want to get an overview of merge requests that are still being reviewed (meaning they are not merged yet), use /homer review list.

Install

[!WARNING] Currently, Homer can only be installed by manually cloning the git repository.

1. Create the Slack app

2. Add Slack emojis

Homer uses custom emojis when posting messages. To have them properly displayed, you will need to add all the emojis under emojis to your Slack organisation.

Customize menu

3. Prerequisites

Be sure to have all those installed:

4. Set the necessary environment variables

Create a .env file containing the following variables:

If you want Homer to connect to an external PostgreSQL database, you can set the following variables:

5. Install and run

# Clone the repo
git clone https://github.com/ManoManoTech/homer.git

# Go to directory that was just created
cd homer

# Install yarn dependencies
yarn install

# Start the database Docker container
docker compose up -d

# Build Homer
yarn build

# Start Homer
yarn start

To check that Homer is working properly, you can go to http://localhost:3000/api/monitoring/healthcheck and check that a donut is displayed.

6. Make your local instance of Homer reachable from outside

You should now be able to use Homer commands on Slack 🎉

Contributing

See CONTRIBUTING.md.