From 3d72376329eb907fcb6345c8c0c0783c84b0d58d Mon Sep 17 00:00:00 2001 From: ebosas Date: Tue, 9 Nov 2021 13:41:04 +0200 Subject: [PATCH] [DeployInfrastructure] --- deployments/pipeline-services.yml | 49 +++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/deployments/pipeline-services.yml b/deployments/pipeline-services.yml index 5e1592e..1c9d7ba 100644 --- a/deployments/pipeline-services.yml +++ b/deployments/pipeline-services.yml @@ -218,9 +218,15 @@ Resources: - Type: FILE_PATH Pattern: ^(cmd/server/|internal/|web/|server.Dockerfile) ExcludeMatchedPattern: false - # - Type: COMMIT_MESSAGE - # Pattern: \[(BuildServer|BuildAll)\] - # ExcludeMatchedPattern: false + - - Type: EVENT + Pattern: PUSH + ExcludeMatchedPattern: false + - Type: HEAD_REF + Pattern: !Sub ^refs/heads/${GitHubBranch}$ + ExcludeMatchedPattern: false + - Type: COMMIT_MESSAGE + Pattern: \[(BuildServer|BuildAll)\] + ExcludeMatchedPattern: false ServiceRole: !Ref CodeBuildServiceRole TimeoutInMinutes: 10 @@ -233,7 +239,9 @@ Resources: AuthType: PERSONAL_ACCESS_TOKEN # Pipeline - PipelineServer: + # Also need a CloudWatch event: + # https://docs.aws.amazon.com/codepipeline/latest/userguide/create-cwe-ecr-source-cfn.html + Pipeline: Type: AWS::CodePipeline::Pipeline Properties: RoleArn: !GetAtt CodePipelineServiceRole.Arn @@ -241,9 +249,10 @@ Resources: Type: S3 Location: !Ref ArtifactBucket Stages: - # Pull the iamge from ECR + # Get source artifacts - Name: Source Actions: + # Get an image from an ECR repository - Name: Source ActionTypeId: Category: Source @@ -256,6 +265,21 @@ Resources: OutputArtifacts: - Name: Source RunOrder: 1 + # Get source from a GitHub repository + - Name: Code + ActionTypeId: + Category: Source + Owner: ThirdParty + Version: 1 + Provider: GitHub + Configuration: + Owner: !Ref GitHubUser + Repo: !Ref GitHubRepo + Branch: !Ref GitHubBranch + # OAuthToken: !Ref GitHubToken + OutputArtifacts: + - Name: Code + RunOrder: 1 # Deploy the service to the ECS/Fargate cluster - Name: Deploy Actions: @@ -281,6 +305,21 @@ Resources: InputArtifacts: - Name: Source + # Webhook: + # Type: AWS::CodePipeline::Webhook + # Properties: + # AuthenticationConfiguration: + # SecretToken: !Ref GitHubToken + # Filters: + # - JsonPath: "$.ref" + # MatchEquals: refs/heads/{Branch} + # Authentication: GITHUB_HMAC + # TargetPipeline: !Ref Pipeline + # TargetAction: Code + # Name: MyWebhook + # TargetPipelineVersion: !GetAtt Pipeline.Version + # RegisterWithThirdParty: false + # # The cache pipeline # PipelineCache: # Type: AWS::CodePipeline::Pipeline