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:
- Introducing AWS SAM Pipelines: Automatically Generate Deployment Pipelines for Serverless Applications
- AWS SAM CLI Command Reference: sam pipeline bootstrap
- AWS SAM CLI Command Reference: sam pipeline init
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.
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.
- Create an AWS account if you do not already have one and login
- Create a GitHub OAuth token (see instructions below).
- Connect AWS CodeBuild to your GitHub account via the AWS Console (see instructions below).
- Go to this app's page on the Serverless Application Repository and click "Deploy"
- Provide the required app parameters and click "Deploy"
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.
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:
- Login to the AWS CodeBuild Console.
- Switch to the region to which you're going to deploy the CI app.
- Click "Create Project".
- Scroll down to the "Source" section.
- Select "GitHub" as the source provider.
- Click "Connect to GitHub".
- 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.
The app has the following parameters:
GitHubOwner
(required) - GitHub username owning the repo.GitHubRepo
(required) - GitHub repo name (just the name, not the full URL).GitHubOAuthToken
(required) - OAuth token used by AWS CodeBuild to connect to GitHub.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_SMALLEnvironmentType
(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
CodeBuildProjectName
- Name of the CodeBuild project.CodeBuildProjectArn
- ARN of the CodeBuild project.ArtifactsBucketName
- Name of the Artifacts S3 bucket used by CodeBuild.ArtifactsBucketArn
- ARN of the Artifacts S3 bucket used by CodeBuild.
This sample code is made available under the MIT-0 license. See the LICENSE file.