Skip to content

Commit

Permalink
chore: minor tweaks to travis configuration (#665)
Browse files Browse the repository at this point in the history
More explicitly skip publishing to DockerHub if this is a PR build. Display
values of `$TRAVIS_TAG` and `$TRAVIS_BRANCH` for more information
when troubleshooting builds (if that's related to publishing).

Release builds from `master` to a `:nightly` tag while (git) tagged builds
will (also) release to `:latest`.
  • Loading branch information
RomainMuller authored Jul 30, 2019
1 parent e7d3a4d commit ac9367a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ services:

before_script:
# Attempt to pre-cache the previous version of the image, to speed build up
- docker pull jsii/superchain:latest || true
- docker pull jsii/superchain:nightly || true

script:
- set -eo pipefail
- docker build --pull --build-arg BUILD_TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg COMMIT_ID="${TRAVIS_COMMIT}" -t "jsii/superchain:latest" ./superchain
- docker run --rm -it --net=host -v ${PWD}:${PWD} -w ${PWD} jsii/superchain:latest ./build.sh
- docker build --pull --build-arg BUILD_TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg COMMIT_ID="${TRAVIS_COMMIT}" -t "jsii/superchain:nightly" ./superchain
- docker run --rm -it --net=host -v ${PWD}:${PWD} -w ${PWD} jsii/superchain:nightly ./build.sh
- echo "TRAVIS_PULL_REQUEST = ${TRAVIS_PULL_REQUEST:-}"
- echo "TRAVIS_TAG = ${TRAVIS_TAG:-}"
- echo "TRAVIS_BRANCH = ${TRAVIS_BRANCH:-}"
- >-
if [ ! -z "${DOCKER_USERNAME+SET}" ] && [ ! -z "${DOCKER_PASSWORD+SET}" ]; then
if [ ${TRAVIS_PULL_REQUEST} = false ] && [ ! -z "${DOCKER_USERNAME+SET}" ] && [ ! -z "${DOCKER_PASSWORD+SET}" ]; then
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
if [ ! -z "${TRAVIS_TAG+SET}" ]; then
docker push jsii/superchain:nightly
if [ "${TRAVIS_TAG:-}" = "${TRAVIS_BRANCH}" ]; then
docker tag jsii/superchain:nightly jsii/superchain:latest
docker push jsii/superchain:latest
else
docker push "jsii/superchain:${TRAVIS_BRANCH}"
fi
fi

0 comments on commit ac9367a

Please sign in to comment.