github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/.circleci/update-impulse.sh (about) 1 #!/bin/bash 2 3 # There are 4 arguments passed in. 4 # $1 is the name of the micro service 5 # $2 is the image id 6 # $3 is the GITHUB OAUTH Key 7 # This script will first get the latest raw of the docker-compose file for impulse and copy it into a local file 8 # It will then replace the entire name of the image for the passed in ($1) micro service with the image name that is built 9 # Finally it will commit the new docker-compose file to impulse with a message 10 11 set -x 12 # echo running script 13 # 14 # echo getting file from GITHUB 15 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/compose-template/config/astro.conf 16 17 # echo search and replace 18 sed -i "s+motivlabs/$1:.*+$2+g" astro.conf 19 # echo pushing file to GITHUB 20 21 if [[ $(echo "$4" | grep -c -i "#nosmoke") == 1 ]]; then 22 echo "no smoke" 23 curl -X PUT -H 'Authorization: token '"$3"'' -d '{"message":"[skip ci] updated janus image","content":"'"$(base64 -w0 astro.conf)"'","sha":'"$(curl -s -X GET -H 'Authorization: token '"$3"'' https://api.github.com/repos/motiv-labs/impulse/contents/docker-tools/compose-template/config/astro.conf | jq .sha)"'}' -L https://api.github.com/repos/motiv-labs/impulse/contents/docker-tools/compose-template/config/astro.conf 24 else 25 echo "smoke" 26 curl -X PUT -H 'Authorization: token '"$3"'' -d '{"message":"updated janus image","content":"'"$(base64 -w0 astro.conf)"'","sha":'"$(curl -s -X GET -H 'Authorization: token '"$3"'' https://api.github.com/repos/motiv-labs/impulse/contents/docker-tools/compose-template/config/astro.conf | jq .sha)"'}' -L https://api.github.com/repos/motiv-labs/impulse/contents/docker-tools/compose-template/config/astro.conf 27 fi 28 29 # update googlecloud image 30 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 31 sed -i "s+motivlabs/$1:.*+$2+g" janus-deployment.yaml 32 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 33 34 # echo finished script