Last active
August 29, 2015 14:18
-
-
Save mlocher/970a3ea260f8185bf8f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# either set them in the script or set those as environment variables | |
# the version must be unique for each deployment and should probably | |
# include at least the commit hash | |
AWS_ACCESS_KEY_ID="" | |
AWS_SECRET_ACCESS_KEY="" | |
AWS_DEFAULT_REGION="" | |
AWS_S3_BUCKET="" | |
AWS_APPLICATION_NAME="" | |
AWS_APPLICATION_ENVIRONMENT="" | |
AWS_APPLICATION_VERSION="" | |
# install the AWS CLI, which isn't installed by default | |
pip install awscli | |
# for rails projects only, reset the database configuration, which | |
# gets adapted for use on Codeship automatically | |
git checkout -- config/database.yml | |
# create the archive and upload it to S3 | |
zip -x \*/.git\* -x .git\* -x \*.hg\* -r "${HOME}/aws_deployment_${AWS_APPLICATION_VERSION}.zip" | |
aws s3 cp "${HOME}/aws_deployment.zip" "s3://${AWS_S3_BUCKET}/subfolder/aws_deployment_${AWS_APPLICATION_VERSION}.zip" | |
# create the new version on ElasticBeanstalk | |
aws elasticbeanstalk create-application-version --application-name "${AWS_APPLICATION_NAME}" --version-label "${AWS_APPLICATION_VERSION}" --source-bundle S3Bucket="${AWS_S3_BUCKET}",S3Key="subfolder/aws_deployment_${AWS_APPLICATION_VERSION}.zip" | |
aws elasticbeanstalk update-environment --environment-name "${AWS_APPLICATION_ENVIRONMENT}" --version-label "${AWS_APPLICATION_VERSION}" | |
# check if the deployment was successful | |
eb_deployment_check "${AWS_APPLICATION_NAME}" "${AWS_APPLICATION_ENVIRONMENT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment