Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Latest commit

 

History

History
66 lines (44 loc) · 5.64 KB

README.md

File metadata and controls

66 lines (44 loc) · 5.64 KB

⚠️ Repository Deprecation Notice ⚠️

This repository, awslabs/aws-sam-codebuild-ci, is scheduled for archival by the end of August 2024. After this date, the repository will become read-only, and no further updates or support will be provided.

We recommend that you migrate to the AWS Serverless Application Model (SAM) CLI's sam pipelines command, which provides a streamlined and integrated experience for automatically generating deployment pipelines for your serverless applications.

The sam pipelines command replaces the functionality provided by this repository and offers a more seamless and up-to-date solution. You can find detailed documentation and guidance on using sam pipelines at the following links:

Please take the necessary steps to migrate your projects to the sam pipelines command before the end of August 2024. After this date, this repository will be archived, and no further updates or support will be provided.

Thank you for your understanding and cooperation.

AWS SAM CodeBuild CI Build Status

This serverless app sets up an AWS CodeBuild Project as a CI solution for a GitHub-based SAM project. Once setup, every time you push to a branch in your GitHub repository, CodeBuild will kick off a build verifying your latest changes. This can be used as an automated check on pull requests (PRs) to your GitHub repo. This app also uses github-codebuild-logs app to allow anyone to view the build logs from AWS CodeBuild Project in pull requests.

Installation

  1. Create an AWS account if you do not already have one and login
  2. Create a GitHub OAuth token (see instructions below).
  3. Connect AWS CodeBuild to your GitHub account via the AWS Console (see instructions below).
  4. Go to this app's page on the Serverless Application Repository and click "Deploy"
  5. Provide the required app parameters and click "Deploy"

Creating a GitHub OAuth token

General instructions for creating a GitHub OAuth token can be found here. When you get to the scopes/permissions page, you should select the "repo" and "admin:repo_hook" scopes, which will automatically select all permissions under those two scopes.

GitHub OAuth Token Permissions

Connect AWS CodeBuild to your GitHub account

Connecting AWS CodeBuild for your account to your GitHub account is a manual step that only needs to be performed once for your account in a given region. To do this, follow these steps:

  1. Login to the AWS CodeBuild Console.
  2. Switch to the region to which you're going to deploy the CI app.
  3. Click "Create Project".
  4. Scroll down to the "Source" section.
  5. Select "GitHub" as the source provider.
  6. Click "Connect to GitHub".
  7. AWS CodeBuild is now connected to your GitHub account. You do not need to complete the Create Project flow and can close the page and return to the installation steps.

Note: If you do not see the "Connect to GitHub" button in step 6 and instead see options to select one of your GitHub repositories, AWS CodeBuild is already connected to your GitHub account and no further action is necessary.

Parameters

The app has the following parameters:

  1. GitHubOwner (required) - GitHub username owning the repo.
  2. GitHubRepo (required) - GitHub repo name (just the name, not the full URL).
  3. GitHubOAuthToken (required) - OAuth token used by AWS CodeBuild to connect to GitHub.
  4. ComputeType (optional) - AWS CodeBuild project compute type to use. See [Create a Build Project (AWS CLI)] (https://docs.aws.amazon.com/codebuild/latest/userguide/create-project.html#create-project-cli) for details. Default: BUILD_GENERAL1_SMALL
  5. EnvironmentType (optional) - Environment type used by AWS CodeBuild. See [Create a Build Project (AWS CLI)] (https://docs.aws.amazon.com/codebuild/latest/userguide/create-project.html#create-project-cli) for details. Default: LINUX_CONTAINER

App Outputs

  1. CodeBuildProjectName - Name of the CodeBuild project.
  2. CodeBuildProjectArn - ARN of the CodeBuild project.
  3. ArtifactsBucketName - Name of the Artifacts S3 bucket used by CodeBuild.
  4. ArtifactsBucketArn - ARN of the Artifacts S3 bucket used by CodeBuild.

License Summary

This sample code is made available under the MIT-0 license. See the LICENSE file.