All Projects → toricls → Github Codebuild Integration

toricls / Github Codebuild Integration

Licence: mit
Run and Integrate AWS CodeBuild with GitHub Push/Pull-Request webhook events.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Github Codebuild Integration

Webhookd
A very simple webhook server launching shell scripts.
Stars: ✭ 250 (+165.96%)
Mutual labels:  webhook, ci
Build
Netlify Build runs the build command, Build Plugins and bundles Netlify Functions.
Stars: ✭ 135 (+43.62%)
Mutual labels:  serverless, ci
Webhook
webhook is a lightweight incoming webhook server to run shell commands
Stars: ✭ 7,201 (+7560.64%)
Mutual labels:  webhook, ci
Next Starter
Next.js Starter using GraphQL, MobX (Next.js, TypeScript, Babel, Express.js, Apollo Client, React Apollo, React Apollo Hooks, GraphQL Codegen, MobX, mobx-state-tree, styled-components, next-optimized-images, Serverless Framework, AWS Lambda, Dotenv)
Stars: ✭ 90 (-4.26%)
Mutual labels:  serverless
Stepfunctions2processing
Configuration with AWS step functions and lambdas which initiates processing from activity state
Stars: ✭ 90 (-4.26%)
Mutual labels:  serverless
Neardb
Simple document db made for infinitely scalable globally distributed reads.
Stars: ✭ 92 (-2.13%)
Mutual labels:  serverless
Lambstatus
[Maintenance mode] Serverless Status Page System
Stars: ✭ 1,323 (+1307.45%)
Mutual labels:  serverless
Lambcycle
🐑🛵 A declarative lambda middleware with life cycle hooks 🐑🛵
Stars: ✭ 88 (-6.38%)
Mutual labels:  serverless
Cirrus
Serverless ML Framework
Stars: ✭ 93 (-1.06%)
Mutual labels:  serverless
Lambda Cost Calculator
Forecast Lambda functions costs 💰
Stars: ✭ 91 (-3.19%)
Mutual labels:  serverless
Daggy
Daggy - Data Aggregation Utility. Open source, free, cross-platform, server-less, useful utility for remote or local data aggregation and streaming
Stars: ✭ 91 (-3.19%)
Mutual labels:  serverless
Serverless Medium Text To Speech
🔊 Serverless-based, text-to-speech service for Medium articles
Stars: ✭ 90 (-4.26%)
Mutual labels:  serverless
Lint Diff
💅 Run eslint only in the changed parts of the code
Stars: ✭ 92 (-2.13%)
Mutual labels:  ci
Embly
A serverless web application framework for collaboration and scale.
Stars: ✭ 90 (-4.26%)
Mutual labels:  serverless
Achievibit
Github Gamification - Achievements system as a GitHub WebHook.
Stars: ✭ 93 (-1.06%)
Mutual labels:  webhook
Pwa Weather
Minimal Weather PWA: Offline, Push Notification and Web Payments
Stars: ✭ 89 (-5.32%)
Mutual labels:  serverless
Coinboss
⚡️💸💰 A Serverless Coinbase tradingbot.
Stars: ✭ 92 (-2.13%)
Mutual labels:  serverless
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+10426.6%)
Mutual labels:  serverless
Cloud Run Button
See Other:
Stars: ✭ 91 (-3.19%)
Mutual labels:  serverless
Irccat
cat to IRC
Stars: ✭ 91 (-3.19%)
Mutual labels:  webhook

github-codebuild-integration (gci)

GitHub release MIT License

gci 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

Commits:

Commits

Pull Request:

Pull Request

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 / gci / GitHub repository

gci allows you to provision multiple installations in one AWS account as follows:

Resources Relation
AWS account : gci installations 1 : n
gci installation : GitHub repository 1 : 1
GitHub repository : AWS CodeBuild project 1 : 1 (will be extended to 1 : n in the future)

As mentioned above, gci 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 gci 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. gci is a missing piece of AWS CodeBuild to make things better. I heard that AWS CodeBuild now supports for building by GitHub push/PR and for updating GitHub status natively. We'll find another motivation to keep developing gci 😛

Requirements

Prerequisites

gci requires the following to be installed on your AWS account.

Required Tools

We use a Makefile to manage gci's lifecycle.

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

The Makefile depends on the following tools:

  • Node.js v14.1.0 or later
  • Yarn 1.22.0 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 gci.

  • Amazon S3
  • Amazon SNS
  • Amazon CloudWatch Events
  • AWS Lambda
  • AWS CodeBuild
  • AWS IAMv
  • AWS CloudFormation

Installation

NOTE: Make sure you already have:
- AWS credentials for AWS CLI access.
- at least one AWS CodeBuild project created.

AWS Account-wide Resource

Create an S3 Bucket to store gci's artifacts to proceed.

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

NOTE: Create an S3 bucket for each AWS region if you use gci in multiple AWS regions.

Per-Project Resources

Clone this repository

$ git clone https://github.com/toricls/github-codebuild-integration.git
$ cd $(pwd)/github-codebuild-integration

Create GitHub Personal Access Token

Open New personal access token page and create one for a gci's installation.

Input token description like codebuild-YOUR_REPO_NAME and enable admin:repo_hook and repo:status as scopes, then click the Generate token button.

Copy the personal access token value and proceed to the next section, "Configure parameters".

Configure parameters

Copy example configuration file and edit it to configure paramters for your GitHub repository.

$ export YOUR_PROJECT_NAME=xxxxxxxxxxxxxxxxx
$ cp env/example.env env/$YOUR_PROJECT_NAME.env
$ editor env/$YOUR_PROJECT_NAME.env

Next table describes about all available parameters of gci.

Required Parameter Name What is this Example
yes S3_SAM_ARTIFACTS_BUCKET_NAME An S3 bucket to store AWS SAM's artifacts. Set the name of the S3 bucket you created on previous step. your.sam.artifacts.bucket
yes GITHUB_REPOSITORY_URL A repository URL you wanted build. Use https style path and make sure trailing '.git' is removed. https://github.com/your-org/your-repo
yes GITHUB_PERSONAL_ACCESS_TOKEN Used for updating GitHub PR's status and Webhook configuration. Minimum scope are admin:repo_hook and repo:status. You can create and obtain a new token via settings page. your-github-personal-access-token
yes GITHUB_TARGET_RESOURCE Choose one event to decide when your CodeBuild project runs. Available value is pr or push. push
optional GITHUB_IGNORE_BRANCH_REGEX Regex string to specify branch name to ignore commit events. This parameter will be enabled only the GITHUB_TARGET_RESOURCE value is push. wip.*
yes AWS_DEFAULT_REGION The region where you want to provision this tool via CloudFormation. us-east-1
yes CODEBUILD_PROJECT_NAME The AWS CodeBuild project name you've already configured for your GitHub repository. your-codebuild-project-name
yes CODEBUILD_PROJECT_REGION The region where you've created a CodeBuild project. You can specify a different region from the region of CloudFormation. us-east-1
optional BUILD_SKIPPED_BY Build invocation will be skipped if the head commit message includes the value of this parameter. This parameter will be used only the GITHUB_TARGET_RESOURCE value is push. "skip ci"

Deploy

Package all artifacts and deploy to your AWS account. You can use this command to update your existing gci installation.

$ make deploy ENV_FILE_PATH=env/$YOUR_PROJECT_NAME.env

Uninstall

You can delete most of generated resources by executing:

$ make destroy ENV_FILE_PATH=env/YOUR-PROJECT-NAME.env

NOTE: CloudFormation doesn't delete CloudWatch's Log Groups. You may want to remove it manually on the AWS Management Console or via the AWS CLI. Also you may want to remove the S3 Bucket(s) you created.

FAQ

Installation & Uninstallation

Q. My IAM role is too weak to install your tool, I guess.

A. Ask your administrator and show him/her the following:

Q: I want to remove all resources of gci from my AWS account.

A: Read the Uninstall section above :X

Changing Configurations

Q: I changed my repository name after gci install.

A: Change the value of GITHUB_REPOSITORY_URL in your env file, then deploy again.

Q: I want to stop CI invoking for a bit.

A: Open GitHubWebhookHandler function (the function name on the Lambda Management Console may something like YOUR-PROJECT-NAME-GitHubWebhookHandler-XXXXXXXXXXX), then set true to the environment variable DO_NOT_RUN.
Don't forget to back that value to false after your quick work.

Feature Request

Q: I need more than one AWS CodeBuild project for my GitHub repository.

A: I totally agree with you! It will be supported in the future. I think the feature will be implemented with a mapping configuration for 'branch name reg-expressions' and 'AWS CodeBuild projects'. But PRs are always welcome 😃

Q. Can you change the icon which shown at PR page's CI status?

A. GitHub shows the avatar of the user who owns the personal access token you provided. You can change the icon by using something like Machine users to create a personal access token for gci.

Contribution

  1. Fork (https://github.com/toricls/github-codebuild-integration/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Create a new Pull Request

Licence

MIT

Author

toricls

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].