Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Add update_ecs job to Circle build, based on TACO
Browse files Browse the repository at this point in the history
  • Loading branch information
atz committed Oct 31, 2018
1 parent 7d7dce0 commit 24d1265
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,35 @@ jobs:
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
docker push ld4p/sinopia_profile_editor:latest
update_ecs:
working_directory: ~/sinopia_profile_editor
docker: # NOT the default
- image: circleci/python:3.7-stretch-node-browsers
steps:
- checkout
- 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
aws configure list # Show confirmation of config
temp_creds=$(aws sts assume-role --role-session-name DevelopersRole --role-arn arn:aws:iam::418214828013:role/DevelopersRole --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 # Confirm again after changes
json=$(aws ecs list-task-definitions --family-prefix sinopia-pe --region us-west-2 --sort DESC --max-items 1)
echo $json
task_arn=$(aws ecs list-task-definitions --family-prefix sinopia-pe --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 "task_arn=$task_arn"
echo "cluster_arn=$cluster_arn"
aws ecs update-service --service sinopia-profile-editor --region us-west-2 --cluster $cluster_arn --task-definition $task_arn --force-new-deployment
workflows:
version: 2
build:
Expand All @@ -90,3 +119,4 @@ workflows:
branches:
only:
- master
- update_ecs

0 comments on commit 24d1265

Please sign in to comment.