Automatic Deployments: Create a CodePipeline
Objective
- Automatically update our application when a change gets pushed to GitHub.
Steps
- Create a CodePipeline.
Defining our pipeline
The pipeline comes in three stages:
- The Source stage pulls the latest code from GitHub.
- The Build stage builds the latest code with CodeBuild according to our
buildspec.yml
file. - The Deploy stage deploys the build artifacts from CodeBuild to the EC2 instances referenced in the deployment group, and starts the application according to our
appspec.yml
file.
Press + to interact
Pipeline:Type: AWS::CodePipeline::PipelineProperties:Name: !Ref AWS::StackNameArtifactStore:Location: !Ref CodePipelineBucketType: S3RoleArn: !GetAtt DeploymentRole.ArnStages:- Name: SourceActions:- Name: SourceActionTypeId:Category: SourceOwner: ThirdPartyVersion: 1Provider: GitHubOutputArtifacts:- Name: SourceConfiguration:Owner: !Ref GitHubOwnerRepo: !Ref GitHubRepoBranch: !Ref GitHubBranchOAuthToken: !Ref GitHubPersonalAccessTokenPollForSourceChanges: falseRunOrder: 1- Name: BuildActions:- Name: BuildActionTypeId:Category: BuildOwner: AWSVersion: 1Provider: CodeBuildInputArtifacts:- Name: SourceOutputArtifacts:- Name: BuildConfiguration:ProjectName: !Ref BuildProjectRunOrder: 1- Name: StagingActions:- Name: StagingInputArtifacts:- Name: BuildActionTypeId:Category: DeployOwner: AWSVersion: 1Provider: CodeDeployConfiguration:ApplicationName: !Ref DeploymentApplicationDeploymentGroupName: !Ref StagingDeploymentGroupRunOrder: 1
Line #25: We don’t need to poll for changes because we’ll set up a webhook to trigger a deployment as soon as GitHub receives a change.
Now, let’s create the webhook that ...
Get hands-on with 1400+ tech skills courses.