<commit_before># gitwebhook

A simple git webhook handler that demonstrates interacting with
github. 
[Modeled after GCF example](https://cloud.google.com/community/tutorials/github-auto-assign-reviewers-cloud-functions)
But by introducing a Bind object, we make the subscription to github automatically by calling a github API
and hence the developer does not have to manually wire things together in the UI, by creating the Bind object
the webhook gets created by Elafros.

## Prerequisites

1. [Setup your development environment](../../DEVELOPMENT.md#getting-started)
2. [Start Elafros](../../README.md#start-elafros)
3. Decide on the DNS name that git can then call. Update elafros/elafros/elaconfig.yaml domainSuffix.
For example I used aikas.org as my hostname, so my elaconfig.yaml looks like so:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: ela-config
  namespace: ela-system
data:
  domainSuffix: aikas.org
```

If you were already running the elafros controllers, you will need to kill the ela-controller in the ela-system namespace for it to pick up the new domain suffix.

4. Create a [personal access token[(https://github.com/settings/tokens) to github repo that you can use to bind webhooks to the Github API. Also decide on a token that your code will authenticate the incoming webhooks from github (accessSoken). Update sample/github/githubsecret.yaml with those values. If your generated access token is '<PASSWORD>' and you choose your secretToken as 'password', you'd modify githubsecret.yaml like so:

```yaml<commit_msg>Fix typo in readme (#22)<commit_after># gitwebhook

A simple git webhook handler that demonstrates interacting with
github. 
[Modeled after GCF example](https://cloud.google.com/community/tutorials/github-auto-assign-reviewers-cloud-functions)
But by introducing a Bind object, we make the subscription to github automatically by calling a github API
and hence the developer does not have to manually wire things together in the UI, by creating the Bind object
the webhook gets created by Elafros.

## Prerequisites

1. [Setup your development environment](../../DEVELOPMENT.md#getting-started)
2. [Start Elafros](../../README.md#start-elafros)
3. Decide on the DNS name that git can then call. Update elafros/elafros/elaconfig.yaml domainSuffix.
For example I used aikas.org as my hostname, so my elaconfig.yaml looks like so:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: ela-config
  namespace: ela-system
data:
  domainSuffix: aikas.org
```

If you were already running the elafros controllers, you will need to kill the ela-controller in the ela-system namespace for it to pick up the new domain suffix.

4. Create a [personal access token](https://github.com/settings/tokens) to github repo that you can use to bind webhooks to the Github API. Also decide on a token that your code will authenticate the incoming webhooks from github (accessSoken). Update sample/github/githubsecret.yaml with those values. If your generated access token is '<PASSWORD>' and you choose your secretToken as 'password', you'd modify githubsecret.yaml like so:

```yaml
{'fraction_non_alphanumeric': 0.07588856868395773, 'fraction_numerical': 0.0038424591738712775, 'mean_word_length': 4.669691470054446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '886418', 'n_tokens_mistral': 899, 'n_tokens_neox': 859, 'n_words': 401}