Implement stage
This commit is contained in:
		
							
								
								
									
										56
									
								
								.github/workflows/build_stage.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								.github/workflows/build_stage.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,56 @@
 | 
			
		||||
name: Build Stage
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
    branches:
 | 
			
		||||
      - master
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  docker:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout
 | 
			
		||||
        uses: actions/checkout@v1
 | 
			
		||||
      - name: Push Tag to Docker Hub
 | 
			
		||||
        uses: opspresso/action-docker@master
 | 
			
		||||
        with:
 | 
			
		||||
          args: --docker
 | 
			
		||||
        env:
 | 
			
		||||
          USERNAME: ${{ secrets.DOCKER_USERNAME }}
 | 
			
		||||
          PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
 | 
			
		||||
          BUILD_PATH: "server"
 | 
			
		||||
          DOCKERFILE: "server/Dockerfile"
 | 
			
		||||
          IMAGE_NAME: "josephbmanley/defend-together"
 | 
			
		||||
          TAG_NAME: "stage"
 | 
			
		||||
          LATEST: "false"
 | 
			
		||||
  cloudformation:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
    - name: Checkout Repo
 | 
			
		||||
      uses: actions/checkout@v2.1.0
 | 
			
		||||
      with:
 | 
			
		||||
        submodules: 'true'
 | 
			
		||||
    - name: Ship to S3
 | 
			
		||||
      uses: jakejarvis/s3-sync-action@master
 | 
			
		||||
      with:
 | 
			
		||||
        args: --follow-symlinks --delete
 | 
			
		||||
      env:
 | 
			
		||||
        SOURCE_DIR: infrastructure/cloudformation
 | 
			
		||||
        AWS_REGION: "us-east-1"
 | 
			
		||||
        DEST_DIR: dt/stage/cloudformation
 | 
			
		||||
        AWS_S3_BUCKET: sumu-stacks
 | 
			
		||||
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
 | 
			
		||||
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
 | 
			
		||||
    - name: Configure AWS Credentials
 | 
			
		||||
      uses: aws-actions/configure-aws-credentials@v1
 | 
			
		||||
      with:
 | 
			
		||||
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
 | 
			
		||||
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
 | 
			
		||||
        aws-region: us-east-1
 | 
			
		||||
    - name: Deploy to AWS CloudFormation
 | 
			
		||||
      uses: aws-actions/aws-cloudformation-github-deploy@v1
 | 
			
		||||
      with:
 | 
			
		||||
        name: dt-infrastructure-stage
 | 
			
		||||
        template: infrastructure/cloudformation/dt/top.yaml
 | 
			
		||||
        capabilities: "CAPABILITY_NAMED_IAM,CAPABILITY_IAM"
 | 
			
		||||
        parameter-overrides: VpcId=${{ secrets.VPC_ID }},SubDomain=stage.dt,Domain=${{ secrets.DOMAIN }},environment=stage,DockerTag=stage,release=stage,PublicSubnets=${{ secrets.SUBNET_IDS }}
 | 
			
		||||
@ -6,13 +6,23 @@ Parameters:
 | 
			
		||||
    Description: The AWS CloudWatch log group to output logs to.
 | 
			
		||||
    Default: "/ecs/dt"
 | 
			
		||||
 | 
			
		||||
  environment:
 | 
			
		||||
    Type: String
 | 
			
		||||
    Description: Name of the environment to use in naming.
 | 
			
		||||
    Default: production
 | 
			
		||||
 | 
			
		||||
  DockerTag:
 | 
			
		||||
    Description: Tag in DockerHub to deploy
 | 
			
		||||
    Type: String
 | 
			
		||||
    Default: "latest"
 | 
			
		||||
 | 
			
		||||
Resources:
 | 
			
		||||
 | 
			
		||||
  LogGroup:
 | 
			
		||||
    Type: AWS::Logs::LogGroup
 | 
			
		||||
    Properties:
 | 
			
		||||
      RetentionInDays: 7
 | 
			
		||||
      LogGroupName: !Ref LogGroupName
 | 
			
		||||
      LogGroupName: !Sub "${LogGroupName}/${environment}"
 | 
			
		||||
 | 
			
		||||
  TaskDefinition:
 | 
			
		||||
    Type: AWS::ECS::TaskDefinition
 | 
			
		||||
@ -20,7 +30,7 @@ Resources:
 | 
			
		||||
      ContainerDefinitions:
 | 
			
		||||
      - Name: defend-together
 | 
			
		||||
        Essential: 'true'
 | 
			
		||||
        Image: "josephbmanley/defend-together:latest"
 | 
			
		||||
        Image: !Sub "josephbmanley/defend-together:${DockerTag}"
 | 
			
		||||
        MemoryReservation: 800
 | 
			
		||||
        PortMappings:
 | 
			
		||||
        - HostPort: 0
 | 
			
		||||
 | 
			
		||||
@ -12,11 +12,15 @@ Parameters:
 | 
			
		||||
    Type: String
 | 
			
		||||
    Description: Name of the release name of the stack version to use.
 | 
			
		||||
    Default: production
 | 
			
		||||
    AllowedValues: ['develop', 'production']
 | 
			
		||||
    AllowedValues: ['develop', 'stage', 'production']
 | 
			
		||||
    ConstraintDescription: "Must be a possible release version."
 | 
			
		||||
  VpcId:
 | 
			
		||||
    Description: ID of the VPC
 | 
			
		||||
    Type: AWS::EC2::VPC::Id
 | 
			
		||||
  DockerTag:
 | 
			
		||||
    Description: Tag in DockerHub to deploy
 | 
			
		||||
    Type: String
 | 
			
		||||
    Default: "latest"
 | 
			
		||||
  
 | 
			
		||||
  #-----------------
 | 
			
		||||
  # Load Balancing 
 | 
			
		||||
@ -95,7 +99,9 @@ Resources:
 | 
			
		||||
    Properties:
 | 
			
		||||
      TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/task.yaml'
 | 
			
		||||
      Parameters:
 | 
			
		||||
        environment: !Ref environment
 | 
			
		||||
        LogGroupName: !Ref LogGroup
 | 
			
		||||
        DockerTag: !Ref DockerTag
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  EcsService:
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user