Skip to content

Commit

Permalink
Update circleci with AWS deploy information
Browse files Browse the repository at this point in the history
Basically a copy of the config from sinopia_profile_editor, with
only changes to the working directory and the name of the
AWS ECS service (sinopia-homepage).  The rest is unchanged.
  • Loading branch information
rsmith11 committed Jan 25, 2019
1 parent 471fb51 commit d833307
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .circleci/config.yml
Expand Up @@ -62,6 +62,30 @@ jobs:
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
docker push ld4p/sinopia_editor:latest
update_ecs:
working_directory: ~/sinopia_editor
docker: # NOT the default
- image: circleci/python:3.7-stretch-node-browsers
steps:
- run: sudo pip install awscli
- run:
name: Update AWS ECS
command: |
mkdir ~/.aws
echo -e "[circle]\naws_access_key_id=$CIRCLE_ACCESS_KEY_ID\naws_secret_access_key=$CIRCLE_SECRET_KEY\n" > ~/.aws/credentials
unset AWS_SESSION_TOKEN
aws configure set region us-west-2
aws configure set output json
temp_creds=$(aws sts assume-role --role-session-name DevelopersRole --role-arn $DEV_ROLE_ARN --profile circle | jq .Credentials)
export AWS_ACCESS_KEY_ID=$(echo "$temp_creds" | jq .AccessKeyId | xargs)
export AWS_SECRET_ACCESS_KEY=$(echo "$temp_creds" | jq .SecretAccessKey | xargs)
export AWS_SESSION_TOKEN=$(echo "$temp_creds" | jq .SessionToken | xargs)
aws configure list # Show confirmation of config
task_arn=$(aws ecs list-task-definitions --family-prefix sinopia-homepage --region us-west-2 --sort DESC --max-items 1 | jq --raw-output --exit-status '.taskDefinitionArns[]')
cluster_arn=$(aws ecs list-clusters --region us-west-2 | jq --raw-output --exit-status '.clusterArns[] | select(contains(":cluster/sinopia-dev"))')
# echo -n "task_arn=$task_arn\ncluster_arn=$cluster_arn\n"
aws ecs update-service --service sinopia-homepage --region us-west-2 --cluster $cluster_arn --task-definition $task_arn --force-new-deployment
workflows:
version: 2
build:
Expand All @@ -77,3 +101,6 @@ workflows:
branches:
only:
- master
- update_ecs:
requires:
- register_image

0 comments on commit d833307

Please sign in to comment.