Giter Club home page Giter Club logo

ci-deploy's Introduction

Deployment Scripts for CI

This project centralises the deployment scripts used by all the projects that use ECR, ECS and Elastic Beanstalk.

We use https://semaphoreci.com/ although it can work with other CI as long as the required environment variables are set and aws is authenticated.

  1. Check if the commit is tagged for release.
  2. If the Docker image doesn't exist in ECR, build it and push it.
  3. For Elastic Beanstalk:
    1. If the application version doesn't exist in Elastic Beanstalk, create it.
    2. Finally trigger the Elastic Beanstalk deployment.
  4. For ECS:
    1. Create the task revision.
    2. Update the service with the revision.
  5. If the tag name starts with base-, the image will be built and pushed but not deployed.

Experimental blue/green EB deployment automation

This is experimental because Elastic Beanstalk is unstable when this option is enabled.

The additional logic is as follows.

  1. Before deployment, clone the Elastic Beanstalk environment.
  2. Swap the URLs before the original environment and the cloned environment.
  3. Deploy to the original environment with the AllAtOnce option.
  4. Swap back the URL.
  5. Terminate the cloned environment.

Environment variables

Required variables:

AWS_ACCESS_KEY_ID=aws-access-key-id
AWS_SECRET_ACCESS_KEY=aws-secret-access-key
AWS_DEFAULT_REGION=ap-southeast-2

APP_ECR_IMAGE=dkr.ecr.ap-southeast-2.amazonaws.com/my-application
APP_ECR_REGION=ap-southeast-2

# These 2 are required if you have "base-*" tags, see above.
BASE_ECR_IMAGE=dkr.ecr.ap-southeast-2.amazonaws.com/my-application-base
BASE_ECR_REGION=ap-southeast-2

CI_DEPLOY_TYPE= # Either eb or ecs

If you're using Elastic Beanstalk:

EB_APP_NAME=MyApplication
EB_ENV_NAME=my-application

If you're using the automated blue/green deployment:

ENABLE_BLUE_GREEN_DEPLOY=1

If you're using ECS:

ECS_CLUSTER=production
ECS_FAMILY=my-application
ECS_SERVICE=my-application

If you're using Rollbar:

ROLLBAR_ACCESS_TOKEN=myPostToken

The following Semaphore environment variables are also used for rollbar

REVISION
SEMAPHORE_SERVER_NAME
DEPLOY_AUTHOR_NAME

If you're using Pact:

PACT_BROKER_URL=https://pact-broker.travellink.com.au
PACT_PARTICIPANT=Quicktravel
STAGE=next

Optional variables

You may override these if you know what you're doing.

SEMAPHORE_PROJECT_DIR=/home/runner/my-application
TAG=0.1.0
JQ_PATH=/usr/bin/jq
EB_WORKER_ENV_NAME=my-application-worker
CLONE_EB_ENV_NAME_SUFFIX=-clone

ci-deploy's People

Contributors

alvinypyim avatar alxberardi avatar blaknite avatar jmortlock avatar sam-wan avatar steffylicious avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

semlabs rbngzlv

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.