More information on lifecycle events and "appspec.yml" file can be found here: http://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html
This can be done through the AWS console.
2 - Install code deploy agent on your instance(s) (and run it) and roles on your IAM for code deploy
This will setup the running agent on your machine to accept and process the code deployments, and also allow the IAM role to communicate with the necessary services to permit the operations securely.
http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-set-up-new-instance.html
$ cp assets/pre-push .git/hooks/pre-push
$ chmod +x ./.git/hooks/pre-push
http://docs.aws.amazon.com/cli/latest/userguide/installing.html
$ aws configure
Usually there will be one application (i.e. Zingo.com). There will be deployment groups for each environment. Name your deployment groups "Prod" and "QA".
Set the S3 bucket name (i.e. my-code-deployments where the system will upload the payload to be deployed after each push)
$ git config codedeploy.s3bucket BUCKET_NAME_HERE
Set the deployment path in your repo, usually its top level. This is the path in the repo that should be deployed (should include the appspec.yml and scripts folders).
$ git config codedeploy.source ./
Set the application name (i.e. Zingo.com, name of your application in AWS code deploy):
$ git config codedeploy.application-name APPLICATION_NAME
Set command line profile to use (i.e. "default", which should be the account the CLI should look for in ~/.aws/credentials):
$ git config codedeploy.profile AWSCLI-PROFILE-NAME
Production:
$ git config codedeploy.master.active 1 (1 or 0, this turns system on for master branch auto-deployments)
$ git config codedeploy.master.application-name ProductionApplicationName
$ git config codedeploy.master.deployment-group ProductionDeploymentGroupName
To pause Production AutoScaling Events during a deployment, optionally add the following:
$ git config codedeploy.master.disable-scaling 1
$ git config codedeploy.master.asg-name ProductionAutoscalingGroupName
QA:
$ git config codedeploy.qa.active 1 (1 or 0, this turns system on for master branch auto-deployments)
$ git config codedeploy.qa.application-name QaApplicationName
$ git config codedeploy.qa.deployment-group QaDeploymentGroupName
To pause QA AutoScaling Events during a deployment, optionally add the following:
$ git config codedeploy.qa.disable-scaling 1
$ git config codedeploy.qa.asg-name QaAutoscalingGroupName
After the above is setup, pushing a commit to branch "master" or "qa" (while the system is active, step #7) will result in the source code in your repository being zipped up and uploaded to s3, and then deployed out to your servers.