Skip to content

Commit 6ebd3f6

Browse files
committed
some scripts for deployment
1 parent 3584183 commit 6ebd3f6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ cache:
1010
script: mvn clean test -Dspring.profiles.active=test
1111

1212
before_deploy:
13+
# install aws cli
1314
- sudo apt-get -y install python-pip
1415
- sudo pip install awscli
16+
# Parse branch name and determine an environment to deploy
1517
- export ENV=$(echo "${TRAVIS_BRANCH}" | perl -ne "print $& if /(?<=deploy\/).*/")
18+
# Switch AWS Role when ENV is prod
19+
- test "${ENV}" = "prod" && source scripts/switch-production-role.sh
20+
# Create an archive to deploy
1621
- scripts/create-archives.sh
1722
deploy:
1823
# upload jar and codedeploy scripts

codedeploy/application_start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ cat << EOF > inventory
1515
localhost
1616
EOF
1717

18-
ansible-playbook -i inventory --connection=local -e "deploy_bucket=${S3_DEPLOY_BUCKET}" site.yml --tags deploy
18+
ansible-playbook -i inventory -c local -e "deploy_bucket=${S3_DEPLOY_BUCKET}" site.yml --tags deploy
1919
)

scripts/switch-production-role.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
credentials=$(aws sts assume-role --role-arn ${PROD_ROLE_ARN} --role-session-name travisci)
4+
5+
export AWS_ACCESS_KEY_ID=$(echo ${credentials} | jq --raw-output .Credentials.AccessKeyId)
6+
export AWS_SECRET_ACCESS_KEY=$(echo ${credentials} | jq --raw-output .Credentials.SecretAccessKey)
7+
export AWS_SESSION_TOKEN=$(echo ${credentials} | jq --raw-output .Credentials.SessionToken)
8+
9+
unset credentials

0 commit comments

Comments
 (0)