<commit_before># ghmm

[![Build Status](https://travis-ci.org/UlfS/ghmm.svg?branch=master)](https://travis-ci.org/UlfS/ghmm)

A GitHub event bot for Mattermost.

## Description

Relays GitHub webhook events to your Mattermost incoming webhook.

## Supported Events

Only a subset of the [GitHub events](https://developer.github.com/v3/activity/events/types/)
are supported right now.

- [PushEvent](https://developer.github.com/v3/activity/events/types/#pushevent)
- [PullRequestEvent](https://developer.github.com/v3/activity/events/types/#pullrequestevent)
- [PullRequestReviewEvent](https://developer.github.com/v3/activity/events/types/#pullrequestreviewevent)
- [PullRequestReviewCommentEvent](https://developer.github.com/v3/activity/events/types/#pullrequestreviewcommentevent)
- [IssueCommentEvent](https://developer.github.com/v3/activity/events/types/#issuecommentevent)
- [StatusEvent](https://developer.github.com/v3/activity/events/types/#statusevent)

Feel free to open a pull request or an issue if you need support for an event.

# Setup

## Create a GitHub Webhook

There is a [page on Github](https://developer.github.com/webhooks/creating/) on
how to do that.

The `config.url` must point to where ghmm will be available.
Make sure it is publicly accessible. If you want to test or use it locally,
see the ["Local Deployment" section](#local-deployment) below.

The `config.content_type` must be `json`.

Choose a `config.secret` between GitHub and ghmm, so that strangers can't just
imitate GitHub.

## Create a Mattermost Incoming Webhook

The [Mattermost documentation](https://docs.mattermost.com/developer/webhooks-incoming.html)
explains how to do that to some degree.

You will get an address which looks similar to this:
http://mattermost.hostname.com/hooks/xxx-generatedkey-xxx


## Deploy ghmm

### Install [`stack`](https://www.haskellstack.org/)

Stack automatically downloads GHC and builds the project.

Follow the [instructions](https://docs.haskellstack.org/en/stable/README/#how-to-install)
to install it.

### Build the Project

`stack build`

The output will also tell you where to find the executable.

### Create an Environment

You need various settings to properly start ghmm, most of them are
self-explanatory.

| Variable             | Description
| -------------------- | ----------------------------------------------------- |
| `PORT`               | Port to start ghmm on                                 |
| `LOG_LEVEL`          | Log level\*                                          |
| `GITHUB_SECRET`      | The secret you chose to share between GitHub and ghmm |
| `MATTERMOST_URL`     | The full url where ghmm is available                  |
| `MATTERMOST_PORT`    | Port where Mattermost is available, usually 443       |
| `MATTERMOST_API_KEY` | The value at the end of the incoming webhook url      |

See `config/dev.example` for how this might look like.

Note that this example config also includes values for the development scripts,
which might not be relevant for you.
<commit_msg>Document default values of configuration<commit_after># ghmm

[![Build Status](https://travis-ci.org/UlfS/ghmm.svg?branch=master)](https://travis-ci.org/UlfS/ghmm)

A GitHub event bot for Mattermost.

## Description

Relays GitHub webhook events to your Mattermost incoming webhook.

## Supported Events

Only a subset of the [GitHub events](https://developer.github.com/v3/activity/events/types/)
are supported right now.

- [PushEvent](https://developer.github.com/v3/activity/events/types/#pushevent)
- [PullRequestEvent](https://developer.github.com/v3/activity/events/types/#pullrequestevent)
- [PullRequestReviewEvent](https://developer.github.com/v3/activity/events/types/#pullrequestreviewevent)
- [PullRequestReviewCommentEvent](https://developer.github.com/v3/activity/events/types/#pullrequestreviewcommentevent)
- [IssueCommentEvent](https://developer.github.com/v3/activity/events/types/#issuecommentevent)
- [StatusEvent](https://developer.github.com/v3/activity/events/types/#statusevent)

Feel free to open a pull request or an issue if you need support for an event.

# Setup

## Create a GitHub Webhook

There is a [page on Github](https://developer.github.com/webhooks/creating/) on
how to do that.

The `config.url` must point to where ghmm will be available.
Make sure it is publicly accessible. If you want to test or use it locally,
see the ["Local Deployment" section](#local-deployment) below.

The `config.content_type` must be `json`.

Choose a `config.secret` between GitHub and ghmm, so that strangers can't just
imitate GitHub.

## Create a Mattermost Incoming Webhook

The [Mattermost documentation](https://docs.mattermost.com/developer/webhooks-incoming.html)
explains how to do that to some degree.

You will get an address which looks similar to this:
http://mattermost.hostname.com/hooks/xxx-generatedkey-xxx


## Deploy ghmm

### Install [`stack`](https://www.haskellstack.org/)

Stack automatically downloads GHC and builds the project.

Follow the [instructions](https://docs.haskellstack.org/en/stable/README/#how-to-install)
to install it.

### Build the Project

`stack build`

The output will also tell you where to find the executable.

### Create an Environment

You need various settings to properly start ghmm, most of them are
self-explanatory.

| Variable             | Description
| -------------------- | ----------------------------------------------------- |
| `PORT`               | Port to start ghmm on (default: `8000`)               |
| `LOG_LEVEL`          | Log level (default: `ERROR`)\*                        |
| `GITHUB_SECRET`      | Secret you chose to share between GitHub and ghmm     |
| `MATTERMOST_URL`     | URL where Mattermost is available                     |
| `MATTERMOST_PORT`    | Port on which Mattermost is available, usually `443`  |
| `MATTERMOST_API_KEY` | Value at the end of the incoming webhook url          |

See `config/dev.example` for how this might look like.

Note that this example config also includes values for the development scripts,
which might not be relevant for you.

{'fraction_non_alphanumeric': 0.12688031393067364, 'fraction_numerical': 0.003924133420536298, 'mean_word_length': 3.375536480686695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 26, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '392301', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1728, 'n_words': 555}