From 59ab38c1ea7c5088fafaa53911d1dc24098b5159 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Mon, 30 Sep 2019 18:31:12 +0200 Subject: [PATCH] Travis: deploy to Docker Hub --- .travis.yml | 8 +++++++ travis/deploy_docker.sh | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 travis/deploy_docker.sh diff --git a/.travis.yml b/.travis.yml index d4133ea..a923ce0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,12 +31,20 @@ jobs: env: TASK=Test CONFIG=Release DOCKER=storm:travis PYTHON=python3 script: travis/build.sh + deploy: + - provider: script + skip_cleanup: true + script: bash travis/deploy_docker.sh stormpy # Docker Storm master in debug mode - os: linux compiler: gcc env: TASK=Test CONFIG=Debug DOCKER=storm:travis-debug PYTHON=python3 script: travis/build.sh + deploy: + - provider: script + skip_cleanup: true + script: bash travis/deploy_docker.sh stormpy # Docker Storm stable - os: linux compiler: gcc diff --git a/travis/deploy_docker.sh b/travis/deploy_docker.sh new file mode 100755 index 0000000..c95d126 --- /dev/null +++ b/travis/deploy_docker.sh @@ -0,0 +1,48 @@ +#!/bin/bash -x + +set -e + +OS=$TRAVIS_OS_NAME + +# Do not deploy if credentials are not given +if [ "${TRAVIS_SECURE_ENV_VARS}" == "false" ]; then + echo "WARNING: Not deploying as no credentials are given." + exit 0; +fi + +# Do not deploy for pull requests +if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then + exit 0; +fi + +echo "Deploying $1 to Dockerhub" + +case $OS in +linux) + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + # Deploy as debug/release + case "$CONFIG" in + *Debug*) + docker commit $1 movesrwth/$1:travis-debug + docker push movesrwth/$1:travis-debug + ;; + *Release*) + docker commit $1 movesrwth/$1:travis + docker push movesrwth/$1:travis + ;; + *) + echo "Unrecognized value of CONFIG: $CONFIG"; exit 1 + ;; + esac + ;; + +osx) + echo "Docker deployment on Mac OSX not used." + exit 1 + ;; + +*) + # Unknown OS + echo "Unsupported OS: $OS" + exit 1 +esac