Skip to content

Commit

Permalink
chore(push-script): updating the push-script for release (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: shubhamchaudhary <[email protected]>
  • Loading branch information
ispeakc0de authored Oct 15, 2020
1 parent 6871b19 commit 23d976c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ env:
- GOARCH=amd64
before_install:
- sleep 15
- sudo apt-get install -y
- sudo apt-get install -y curl
- sudo apt-get install -y shellcheck
- sudo apt-get install -y curl shellcheck

jobs:
include:
Expand All @@ -24,7 +22,7 @@ jobs:
- stage: build chaos-test images
name: build docker image chaos-test
script:
- make chaos-test
- make chaostest

notifications:
email:
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ deps: _build_check_docker

_build_tests_chaostest_image:
@echo "INFO: Building container image for performing chaostoolkit tests"
cd chaos-test && docker build -t litmuschaos/chaos-test .
cd chaos-test && docker build -t litmuschaos/chaostoolkit:ci .

_push_tests_chaostest_image:
@echo "INFO: Publish container litmuschaos/chaos-test"
cd chaos-test/buildscripts && ./push
@echo "INFO: Publish container litmuschaos/chaostoolkit:ci"
REPONAME="litmuschaos" IMGNAME="chaostoolkit" IMGTAG="ci" ./chaos-test/buildscripts/push

chaostest: deps _build_tests_chaostest_image _push_tests_chaostest_image

37 changes: 30 additions & 7 deletions chaos-test/buildscripts/push
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
#!/bin/bash
set -e

IMAGEID=$( docker images -q litmuschaos/chaos-test )
if [ -z "${REPONAME}" ]
then
REPONAME="litmuschaos"
fi

if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ];
if [ -z "${IMGNAME}" ] || [ -z "${IMGTAG}" ];
then
docker login -u "${DNAME}" -p "${DPASS}";
#Push to docker hub repository with latest tag
docker tag ${IMAGEID} litmuschaos/chaos-test:latest
docker push litmuschaos/chaos-test:latest;
echo "Image details are missing. Nothing to push.";
exit 1
fi

IIMAGEID=$( sudo docker images -q ${REPONAME}/${IMGNAME}:${IMGTAG} )

if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ];
then
sudo docker login -u "${DNAME}" -p "${DPASS}";
# Push image to docker hub
echo "Pushing ${REPONAME}/${IMGNAME}:${IMGTAG} ...";
sudo docker push ${REPONAME}/${IMGNAME}:${IMGTAG} ;
if [ ! -z "${TRAVIS_TAG}" ] ;
then
# Push with different tags if tagged as a release
# When github is tagged with a release, then Travis will
# set the release tag in env TRAVIS_TAG
echo "Pushing ${REPONAME}/${IMGNAME}:${TRAVIS_TAG} ...";
sudo docker tag ${IMAGEID} ${REPONAME}/${IMGNAME}:${TRAVIS_TAG}
sudo docker push ${REPONAME}/${IMGNAME}:${TRAVIS_TAG};
echo "Pushing ${REPONAME}/${IMGNAME}:latest ...";
sudo docker tag ${IMAGEID} ${REPONAME}/${IMGNAME}:latest
sudo docker push ${REPONAME}/${IMGNAME}:latest;
fi;
else
echo "No docker credentials provided. Skip uploading litmuschaos/chaostest:latest to docker hub";
echo "No docker credentials provided. Skip uploading ${REPONAME}/${IMGNAME}:${IMGTAG} to docker hub";
fi;

0 comments on commit 23d976c

Please sign in to comment.