Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

toricls/github-codebuild-integration

Repository files navigation

GitHub releaseMIT 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:

ResourcesRelation
AWS account : gci installations1 : n
gci installation : GitHub repository1 : 1
GitHub repository : AWS CodeBuild project1 : 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

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

Input token description likecodebuild-YOUR_REPO_NAME and enableadmin:repo_hook andrepo:status as scopes, then click theGenerate 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.

RequiredParameter NameWhat is thisExample
yesS3_SAM_ARTIFACTS_BUCKET_NAMEAn S3 bucket to store AWS SAM's artifacts. Set the name of the S3 bucket you created on previous step.your.sam.artifacts.bucket
yesGITHUB_REPOSITORY_URLA repository URL you wanted build. Use https style path and make sure trailing '.git' is removed.https://github.com/your-org/your-repo
yesGITHUB_PERSONAL_ACCESS_TOKENUsed for updating GitHub PR's status and Webhook configuration. Minimum scope areadmin:repo_hook andrepo:status. You can create and obtain a new token viasettings page.your-github-personal-access-token
yesGITHUB_TARGET_RESOURCEChoose one event to decide when your CodeBuild project runs. Available value ispr orpush.push
optionalGITHUB_IGNORE_BRANCH_REGEXRegex string to specify branch name to ignore commit events. This parameter will be enabled only theGITHUB_TARGET_RESOURCE value ispush.wip.*
yesAWS_DEFAULT_REGIONThe region where you want to provision this tool via CloudFormation.us-east-1
yesCODEBUILD_PROJECT_NAMEThe AWS CodeBuild project name you've already configured for your GitHub repository.your-codebuild-project-name
yesCODEBUILD_PROJECT_REGIONThe region where you've created a CodeBuild project. You can specify a different region from the region of CloudFormation.us-east-1
optionalBUILD_SKIPPED_BYBuild 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 ispush."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 theUninstall section above :X

Changing Configurations

Q: I changed my repository name after gci install.

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

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

A: OpenGitHubWebhookHandler function (the function name on the Lambda Management Console may something likeYOUR-PROJECT-NAME-GitHubWebhookHandler-XXXXXXXXXXX), then settrue to the environment variableDO_NOT_RUN.
Don't forget to back that value tofalse 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 likeMachine 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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp