From c413795b8103def4798fd3089a01ed0065c06c68 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Mon, 19 Sep 2016 13:43:28 -0500 Subject: [PATCH] Setup automated deploys This commit sets up automated deploys using Travis. The inspiration for many of these changes came from the [Micropurchase app's config](https://github.com/18F/micropurchase/blob/develop/.travis.yml). To enable automated deploys, this commit does the following: - Add a deploy script that takes an environment as an argument and deploys to the appropriate app on cloud.gov - Modify the Travis configuration to add the keys that travis needs to deploy to cloud.gov closes #204 --- .travis.yml | 16 +++++++++++++++- bin/deploy.sh | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 bin/deploy.sh diff --git a/.travis.yml b/.travis.yml index 0dc142c..9d252c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,24 @@ before_script: bundler_args: "--deployment --jobs=3 --retry=3 --without development" cache: bundler env: -- DB=postgresql + global: + - DB=postgresql + - CF_USERNAME=18f-dolores-deployer + - secure: AJwrGkiXOnUIXORLLnFITHAPK4djtY0dvQRYRTlmSJD8hq3/AUMhmhhFRVlSB5cje7Mp4Sm9ChiUBoB029tj1nSGZZGCAEoVdlv1/wwHMAlS3Cou/O+AhxQTEg75wFNxNJArYPyqjXQxETRLKBv19z28EUADEZ+x3EHb4KNvnD5PL/tXn4snFh090w0BYbzkx1vHBURajuxeSPYT46kz+gZeU/ogZ9Ur3sFzHJjDJkS0EgicYIm13GrLokXv7mDbZa26OKRc5Sh0X19xHuPMl5USmXXNF+avQaaf0bEq84GIwjiYdGPfQP2MF/MX8U5FSxjWCOLYQGY/qZSgzj4jjEhxXtzCA55hPRinIh/PyJnQ8qeTB5FhJNU9JhTnGB9EaWDpfF1q23oQ6SeHRgUiqUJU3Vqxamlcdg7kuwh8syabgGflb8kpmQLUPC3AsyOMM0OG9ZxrbxgLf3SEg6x+fDQI8EOfg8cKNSGpu6FZIzVgVvCurG7CnrjnH8fDht+3GVx7J0F48/pXujcfgQcQ+L3eOF6NywmeNr8qccYcthbHKS3g8fUPVfHqpUlFpw/tQfEjdlFUktbSeuqW09xXsuOEbsZVQktVS9wwYYBbVVosbcKPDF5yAk7R9YuhnlZ0LLlJ5etDAHnI8HAMmhAQy27LnmJNTRkcbg0wj86ESZg= language: ruby rvm: - ruby-2.3.1 sudo: false script: - bundle exec rake +deploy: +- provider: script + script: "./bin/deploy.sh staging" + skip_cleanup: true + on: + branch: develop +- provider: script + script: "./bin/deploy.sh production" + skip_cleanup: true + on: + branch: master diff --git a/bin/deploy.sh b/bin/deploy.sh new file mode 100644 index 0000000..be43005 --- /dev/null +++ b/bin/deploy.sh @@ -0,0 +1,18 @@ +set -e + +API="https://api.cloud.gov" +ORG="18f" +SPACE="dolores" +ENVIRONMENT=$1 + +if [ $ENVIRONMENT = 'production' ]; then + NAME="dolores-app" +elif [ $ENVIRONMENT = 'staging' ]; then + NAME="dolores-staging" +else + echo "Unknown environment: $ENVIRONMENT" + exit +fi + +cf login --a $API --u $CF_USERNAME --p $CF_PASSWORD --o $ORG -s $SPACE +cf push $NAME