Skip to content

Commit

Permalink
updating image in circle (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxranger committed Mar 21, 2021
1 parent 833d5d9 commit fa3adfe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
docker push motivlabs/janus:latest
echo "Pushed Latest Image Name"
echo "Running Script to Update Impulse Docker-Compose with Correct Image"
.circleci/update-impulse.sh "janus" ${IMAGE_NAME} ${GITHUB_OAUTH}
echo "Impulse Updated"
workflows:
version: 2
build:
Expand Down
30 changes: 30 additions & 0 deletions .circleci/update-impulse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# There are 4 arguments passed in.
# $1 is the name of the micro service
# $2 is the image id
# $3 is the GITHUB OAUTH Key
# This script will first get the latest raw of the docker-compose file for impulse and copy it into a local file
# It will then replace the entire name of the image for the passed in ($1) micro service with the image name that is built
# Finally it will commit the new docker-compose file to impulse with a message

set -x
# echo running script
#
# echo getting file from GITHUB
# curl --user $3:$4 "https://api.bitbucket.org/2.0/repositories/motivlabs/impulse/src/master/docker-tools/docker-compose.yml" > docker-compose.yml
curl -H 'Authorization: token '"$3"'' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/motiv-labs/impulse/contents/docker-tools/docker-compose.yml

# echo search and replace
sed -i "s+motivlabs/$1:.*+$2+g" docker-compose.yml
# echo pushing file to GITHUB

# curl --user $3:$4 "https://api.bitbucket.org/2.0/repositories/motivlabs/impulse/src" -F /docker-tools/docker-compose.yml=@docker-compose.yml -F message="updated $1 image"
curl -X PUT -H 'Authorization: token '"$3"'' -d '{"message":"updated janus image","content":"'"$(base64 -w0 docker-compose.yml)"'","sha":'"$(curl -s -X GET -H 'Authorization: token '"$3"'' https://api.github.com/repos/motiv-labs/impulse/contents/docker-tools/docker-compose.yml | jq .sha)"'}' -L https://api.github.com/repos/motiv-labs/impulse/contents/docker-tools/docker-compose.yml

# update googlecloud image
curl -H 'Authorization: token '"$3"'' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/motiv-labs/impulse-googlecloud/contents/impulse/janus-deployment.yaml
sed -i "s+motivlabs/$1:.*+$2+g" janus-deployment.yaml
curl -X PUT -H 'Authorization: token '"$3"'' -d '{"message":"updated janus image","content":"'"$(base64 -w0 janus-deployment.yaml)"'","sha":'"$(curl -s -X GET -H 'Authorization: token '"$3"'' https://api.github.com/repos/motiv-labs/impulse-googlecloud/contents/impulse/janus-deployment.yaml | jq .sha)"'}' -L https://api.github.com/repos/motiv-labs/impulse-googlecloud/contents/impulse/janus-deployment.yaml

# echo finished script

0 comments on commit fa3adfe

Please sign in to comment.