<commit_before># github-codebuild-integration

[![GitHub release](http://img.shields.io/github/release/toricls/github-codebuild-integration.svg?style=flat-square)][release]
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]

[release]: https://github.com/toricls/github-codebuild-integration/releases
[license]: https://github.com/toricls/github-codebuild-integration/blob/master/LICENSE

github-codebuild-integration is a CI dispatching/status handling tool to integrate AWS CodeBuild with GitHub Push/Pull-Request webhook events, created with love of Serverless Architecture.

## Overview

Yay, Serverless!

[![Overview](https://github.com/toricls/github-codebuild-integration/wiki/res/overview-800x463.png)](https://github.com/toricls/github-codebuild-integration/wiki/res/overview.png)

**Commits:**

[![Commits](https://github.com/toricls/github-codebuild-integration/wiki/res/commits-300x234.png)](https://github.com/toricls/github-codebuild-integration/wiki/res/commits.png)

**Pull Request:**

[![Pull Request](https://github.com/toricls/github-codebuild-integration/wiki/res/pr-600x394.png)](https://github.com/toricls/github-codebuild-integration/wiki/res/pr.png)

## Features

- Invoking a pre-configured AWS CodeBuild project by hooking Push or Pull Reqeust webhook events.
- Setting GitHub's CI status based on status/result of builds on AWS CodeBuild.

### AWS account / github-codebuild-integration / GitHub repository

github-codebuild-integration allows you to provision multiple installations in one AWS account as follows:

Resources | Relation
---------- | ----------
AWS account : github-codebuild-integration installations | 1 : n
github-codebuild-integration installation : GitHub repository | 1 : 1
GitHub repository : AWS CodeBuild project | 1 : 1 (will be extended to 1 : n in the future)

As mentioned above, github-codebuild-integration can be installed as many as you want to integrate with your GitHub repositories. If you want to build 3 repositories, you may provision 3 of github-codebuild-integration installation for instance.

## Background

GitHub has a feature to show each commit's status like 'success', 'failure', 'pending' on their Commit/PR pages, and based on that status, we can protect any branches from CI failed branch to be merged.

GitHub accepts status creation via their APIs and many third-party CI services implement functionalities to integrate with that APIs to show their job status on GitHub.

On the other hand, AWS CodeBuild doesn't have such a feature to save its build project status to GitHub for now. github-codebuild-integration is a missing piece of AWS CodeBuild to make things better.

## Requirements

### Prerequisites

github-codebuild-integration requires the following to be installed on your AWS account.

### Required Tools

We provide Makefile to you to manage github-codebuild-integration's lifecycle.

- GNU Make (if you are using macOS, `brew install make` is handy)

Provided commands use the following tools:

- Node.js v6.10 or later
- Yarn v0.27.5 or later
- AWS-CLI 1.11.132 or later
- curl

### Required Accounts & Resources

- AWS Account
- `AdministratorAccess` to your AWS Account (to use AWS CloudFormation in the installation command)
- GitHub Account

And the listed resources below are created in the process of installation, which means they are required as available AWS services in a region where you want to run github-codebuild-integration.

- Amazon S3
- Amazon SNS
- AWS Lambda
- AWS Step Functions
- AWS CodeBuild
- AWS IAM
- AWS CloudFormation

## Installation

_**NOTE: Make sure the following before proceeding.**_  
_**- You've loaded your [AWS credentials](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).**_  
_**- You've already created one AWS CodeBuild project at least.**_

### AWS Account-wide Resource

We have to create an S3 Bucket to store github-codebuild-integration's artifacts to provision it.

```
$ aws s3api create-bucket \
    --bucket {YOUR_S3_BUCKET_NAME} \
    --create-bucket-configuration LocationConstraint=$AWS_DEFAULT_REGION
```

_**NOTE: If you plan installing github-codebuild-integration into multiple AWS regions, you may create an S3 bucket for each AWS region.**_

### Per-Project Resources<commit_msg>README: Replace http links to https<commit_after># github-codebuild-integration

[![GitHub release](https://img.shields.io/github/release/toricls/github-codebuild-integration.svg?style=flat-square)][release]
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]

[release]: https://github.com/toricls/github-codebuild-integration/releases
[license]: https://github.com/toricls/github-codebuild-integration/blob/master/LICENSE

github-codebuild-integration is a CI dispatching/status handling tool to integrate AWS CodeBuild with GitHub Push/Pull-Request webhook events, created with love of Serverless Architecture.

## Overview

Yay, Serverless!

[![Overview](https://github.com/toricls/github-codebuild-integration/wiki/res/overview-800x463.png)](https://github.com/toricls/github-codebuild-integration/wiki/res/overview.png)

**Commits:**

[![Commits](https://github.com/toricls/github-codebuild-integration/wiki/res/commits-300x234.png)](https://github.com/toricls/github-codebuild-integration/wiki/res/commits.png)

**Pull Request:**

[![Pull Request](https://github.com/toricls/github-codebuild-integration/wiki/res/pr-600x394.png)](https://github.com/toricls/github-codebuild-integration/wiki/res/pr.png)

## Features

- Invoking a pre-configured AWS CodeBuild project by hooking Push or Pull Reqeust webhook events.
- Setting GitHub's CI status based on status/result of builds on AWS CodeBuild.

### AWS account / github-codebuild-integration / GitHub repository

github-codebuild-integration allows you to provision multiple installations in one AWS account as follows:

Resources | Relation
---------- | ----------
AWS account : github-codebuild-integration installations | 1 : n
github-codebuild-integration installation : GitHub repository | 1 : 1
GitHub repository : AWS CodeBuild project | 1 : 1 (will be extended to 1 : n in the future)

As mentioned above, github-codebuild-integration can be installed as many as you want to integrate with your GitHub repositories. If you want to build 3 repositories, you may provision 3 of github-codebuild-integration installation for instance.

## Background

GitHub has a feature to show each commit's status like 'success', 'failure', 'pending' on their Commit/PR pages, and based on that status, we can protect any branches from CI failed branch to be merged.

GitHub accepts status creation via their APIs and many third-party CI services implement functionalities to integrate with that APIs to show their job status on GitHub.

On the other hand, AWS CodeBuild doesn't have such a feature to save its build project status to GitHub for now. github-codebuild-integration is a missing piece of AWS CodeBuild to make things better.

## Requirements

### Prerequisites

github-codebuild-integration requires the following to be installed on your AWS account.

### Required Tools

We provide Makefile to you to manage github-codebuild-integration's lifecycle.

- GNU Make (if you are using macOS, `brew install make` is handy)

Provided commands use the following tools:

- Node.js v6.10 or later
- Yarn v0.27.5 or later
- AWS-CLI 1.11.132 or later
- curl

### Required Accounts & Resources

- AWS Account
- `AdministratorAccess` to your AWS Account (to use AWS CloudFormation in the installation command)
- GitHub Account

And the listed resources below are created in the process of installation, which means they are required as available AWS services in a region where you want to run github-codebuild-integration.

- Amazon S3
- Amazon SNS
- AWS Lambda
- AWS Step Functions
- AWS CodeBuild
- AWS IAM
- AWS CloudFormation

## Installation

_**NOTE: Make sure the following before proceeding.**_  
_**- You've loaded your [AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).**_
_**- You've already created one AWS CodeBuild project at least.**_

### AWS Account-wide Resource

We have to create an S3 Bucket to store github-codebuild-integration's artifacts to provision it.

```
$ aws s3api create-bucket \
    --bucket {YOUR_S3_BUCKET_NAME} \
    --create-bucket-configuration LocationConstraint=$AWS_DEFAULT_REGION
```

_**NOTE: If you plan installing github-codebuild-integration into multiple AWS regions, you may create an S3 bucket for each AWS region.**_

### Per-Project Resources
{'fraction_non_alphanumeric': 0.0983928777893398, 'fraction_numerical': 0.010174586657417042, 'mean_word_length': 4.616883116883117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 19, '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': '1384524', 'n_tokens_mistral': 2586, 'n_tokens_neox': 2348, 'n_words': 870}