|
1 |
| -# tako |
| 1 | +## tako |
2 | 2 |
|
3 |
| -tako is a Github notifier for Slack. It is written in Clojure and runs on |
4 |
| -AWS lambda. |
| 3 | +🐙 tako is a Github notifier for Slack. It is written in Clojure and can be deployed to AWS lambda. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## Why? |
| 8 | + |
| 9 | +These are some (personal?) reasons to use tako: |
| 10 | + |
| 11 | +- **Email kinda sucks**. By default Github sends you an email everytime someone creates a pull request or issue on a project you follow, or when you are mentioned, etc. Being an *inbox zero* freak myself, depending on email to stay on top of what's going on my your github account is rather cumbersome. |
| 12 | +- **Slack does a decent job** You probably use it more than email anyway. Slack messages are easier to skim and keep clean. Most notifications don't require you to reply back. |
| 13 | + |
| 14 | + |
| 15 | +## Requirements |
| 16 | + |
| 17 | +- [lein](http://leiningen.org) |
| 18 | +- A [Github token](https://github.com/settings/tokens) |
| 19 | +- A [Slack Webhook URL](https://slack.com/apps/new/A0F7XDUAZ-incoming-webhooks) pointing to a channel of your preference. |
| 20 | + |
| 21 | +To run locally: |
| 22 | + |
| 23 | + lein run YOUR_GITHUB_TOKEN YOUR_SLACK_WEBHOOK_URL |
| 24 | + |
| 25 | +You can also create an jar with `lein uberjar`. |
| 26 | + |
| 27 | +## Running from AWS lambda |
| 28 | + |
| 29 | +In my current setup I have `tako` running on top of [AWS lambda](https://aws.amazon.com/lambda/). This is why it is cool: |
| 30 | + |
| 31 | +- [It is free](https://aws.amazon.com/lambda/pricing/), at least for this use case. Since `tako` runs just a few times per hour, it will never be executed more than one million times a month (which is when Amazon starts charging you). |
| 32 | +- You don't need to care about configure/maintain a server |
| 33 | +- It is easy to update/deploy the code |
| 34 | + |
| 35 | +There's one caveat though: AWS can be configured to run every N minutes; the minimum N is 5, so worst case scenario you receive the notifications 5 minutes after they were produced. Not a big deal for me, but worth taking into account. |
| 36 | + |
| 37 | +That said, all you have to do is create a new AWS lambda function and configure it to run every 5 minutes. The steps are slightly modified from [this guide](http://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html): |
| 38 | + |
| 39 | +0: Build a jar |
| 40 | +```bash |
| 41 | +git clone [email protected]:casidiablo/tako.git |
| 42 | +cd tako |
| 43 | +export GITHUB_TOKEN=your token |
| 44 | +export SLACK_WEBHOOK_URL=the slack webhook url |
| 45 | +./build-jar |
| 46 | + |
| 47 | +# a jar will be assembled in tako/target/tako.jar |
| 48 | +``` |
| 49 | +1. Sign in to the AWS Management Console and open the AWS Lambda console at https://console.aws.amazon.com/lambda/ |
| 50 | +2. Choose Create a Lambda function. |
| 51 | +3. In **Step 1: Select blueprint**, choose the **lambda-canary** blueprint. |
| 52 | +4. In **Step 2: Configure event source**: |
| 53 | + - In **Event source type**, choose **CloudWatch Events - Schedule**. |
| 54 | + - In **Name** type a name (for example, **Github Poller**). Then, this name appears in the list of event sources in the console. |
| 55 | + - In **Schedule expression**, specify **rate(5 minutes)**. |
| 56 | +5. In **Step 3**: Configure function, do the following: |
| 57 | + - Set the function name to `tako` |
| 58 | + - In **Runtime**, specify *Java 8* |
| 59 | + - In **Handler** type `tako.core::handler` |
| 60 | + - In **Role**, choose basic execution role. |
| 61 | + - In the **Lambda function code**, choose the jar produced in step `0` |
| 62 | + - In **Memory (MB)**, set the dropdown to 256 |
| 63 | + - In **Timeout**, configure it to be 30 seconds |
| 64 | +6. In **Step 4: Review**, review the configuration and then choose **Create Function**. The function must look [like this](http://i.imgur.com/3tduRGF.png). |
| 65 | + |
| 66 | +### Updating code |
| 67 | + |
| 68 | +You can upload changes from the command line by running: |
| 69 | + |
| 70 | + # make sure you have awscli installed and configured |
| 71 | + ./lambda-deploy |
| 72 | + |
| 73 | +Or by building a new jar and uploading it manually using the AWS web console. |
0 commit comments