Skip to content

Commit 23d976c

Browse files
authored
chore(push-script): updating the push-script for release (#11)
Signed-off-by: shubhamchaudhary <[email protected]>
1 parent 6871b19 commit 23d976c

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

.travis.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ env:
99
- GOARCH=amd64
1010
before_install:
1111
- sleep 15
12-
- sudo apt-get install -y
13-
- sudo apt-get install -y curl
14-
- sudo apt-get install -y shellcheck
12+
- sudo apt-get install -y curl shellcheck
1513

1614
jobs:
1715
include:
@@ -24,7 +22,7 @@ jobs:
2422
- stage: build chaos-test images
2523
name: build docker image chaos-test
2624
script:
27-
- make chaos-test
25+
- make chaostest
2826

2927
notifications:
3028
email:

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ deps: _build_check_docker
2626

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

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

3535
chaostest: deps _build_tests_chaostest_image _push_tests_chaostest_image
36-

chaos-test/buildscripts/push

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
#!/bin/bash
22
set -e
33

4-
IMAGEID=$( docker images -q litmuschaos/chaos-test )
4+
if [ -z "${REPONAME}" ]
5+
then
6+
REPONAME="litmuschaos"
7+
fi
58

6-
if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ];
9+
if [ -z "${IMGNAME}" ] || [ -z "${IMGTAG}" ];
710
then
8-
docker login -u "${DNAME}" -p "${DPASS}";
9-
#Push to docker hub repository with latest tag
10-
docker tag ${IMAGEID} litmuschaos/chaos-test:latest
11-
docker push litmuschaos/chaos-test:latest;
11+
echo "Image details are missing. Nothing to push.";
12+
exit 1
13+
fi
14+
15+
IIMAGEID=$( sudo docker images -q ${REPONAME}/${IMGNAME}:${IMGTAG} )
16+
17+
if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ];
18+
then
19+
sudo docker login -u "${DNAME}" -p "${DPASS}";
20+
# Push image to docker hub
21+
echo "Pushing ${REPONAME}/${IMGNAME}:${IMGTAG} ...";
22+
sudo docker push ${REPONAME}/${IMGNAME}:${IMGTAG} ;
23+
if [ ! -z "${TRAVIS_TAG}" ] ;
24+
then
25+
# Push with different tags if tagged as a release
26+
# When github is tagged with a release, then Travis will
27+
# set the release tag in env TRAVIS_TAG
28+
echo "Pushing ${REPONAME}/${IMGNAME}:${TRAVIS_TAG} ...";
29+
sudo docker tag ${IMAGEID} ${REPONAME}/${IMGNAME}:${TRAVIS_TAG}
30+
sudo docker push ${REPONAME}/${IMGNAME}:${TRAVIS_TAG};
31+
echo "Pushing ${REPONAME}/${IMGNAME}:latest ...";
32+
sudo docker tag ${IMAGEID} ${REPONAME}/${IMGNAME}:latest
33+
sudo docker push ${REPONAME}/${IMGNAME}:latest;
34+
fi;
1235
else
13-
echo "No docker credentials provided. Skip uploading litmuschaos/chaostest:latest to docker hub";
36+
echo "No docker credentials provided. Skip uploading ${REPONAME}/${IMGNAME}:${IMGTAG} to docker hub";
1437
fi;

0 commit comments

Comments
 (0)