From 41fe43b33c8ed05d03a1b4d00f4c085ea43ee154 Mon Sep 17 00:00:00 2001 From: James Hewitt Date: Thu, 8 Apr 2021 23:04:06 +0100 Subject: [PATCH] Publish docker image Add a deploy stage to the travis build to publish a latest docker image to a registry for master and releases. --- .travis.yml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c526ef2..f2fa55c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,12 @@ dist: xenial language: python +services: + - docker + +env: + - DOCKER_REGISTRY=docker.io DOCKER_REPOSITORY=huashengdun/webssh + python: - "2.7" - "3.4" @@ -17,6 +23,26 @@ install: script: - pytest --cov=webssh - flake8 - + after_success: - codecov + +jobs: + include: + - stage: deploy + script: docker build -t webssh:build . + deploy: + - provider: script + script: >- + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && + docker tag webssh:build "${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}:latest" && + docker push "${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}:latest" + on: + branch: master + - provider: script + script: >- + docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" && + docker tag webssh:build "${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}:$TRAVIS_TAG" && + docker push "${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}:$TRAVIS_TAG" + on: + tags: true