From 94dbbb08424f5a97230642d0d60d50656c39039a Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 27 Oct 2018 15:12:12 +0200 Subject: [PATCH 1/2] push pull requests to docker hub --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 36ef16fc4..e81d5ed9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,6 +57,11 @@ after_success: docker push $REPO; echo "Pushed to" $REPO; AUTO_DEPLOY=true; + elif [ "$TRAVIS_PULL_REQUEST" == "true" ]; then + docker build -f Dockerfile -t $REPO:$TRAVIS_PULL_REQUEST_BRANCH .; + docker push $REPO:$TRAVIS_PULL_REQUEST_BRANCH; + echo "Pushed to" $REPO:$TRAVIS_PULL_REQUEST_BRANCH; + AUTO_DEPLOY=true; else docker build -f Dockerfile -t $REPO:$TRAVIS_BRANCH .; docker push $REPO:$TRAVIS_BRANCH; @@ -88,7 +93,7 @@ after_success: fi git commit -m "Adding lupo git variables for latest commit"; - git push "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git" master; + git push "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git"; fi notifications: From 7f05458eee6fa3a01592d104ce1923e1a86ba5ed Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 27 Oct 2018 15:50:03 +0200 Subject: [PATCH 2/2] tell travis to push to pull request branch --- .travis.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index e81d5ed9d..2f0228202 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,16 +52,16 @@ after_success: docker push $REPO:$TRAVIS_TAG; echo "Pushed to" $REPO:$TRAVIS_TAG; AUTO_DEPLOY=true; - elif [ "$TRAVIS_BRANCH" == "master" ]; then - docker build -f Dockerfile -t $REPO .; - docker push $REPO; - echo "Pushed to" $REPO; - AUTO_DEPLOY=true; elif [ "$TRAVIS_PULL_REQUEST" == "true" ]; then docker build -f Dockerfile -t $REPO:$TRAVIS_PULL_REQUEST_BRANCH .; docker push $REPO:$TRAVIS_PULL_REQUEST_BRANCH; echo "Pushed to" $REPO:$TRAVIS_PULL_REQUEST_BRANCH; AUTO_DEPLOY=true; + elif [ "$TRAVIS_BRANCH" == "master" ]; then + docker build -f Dockerfile -t $REPO .; + docker push $REPO; + echo "Pushed to" $REPO; + AUTO_DEPLOY=true; else docker build -f Dockerfile -t $REPO:$TRAVIS_BRANCH .; docker push $REPO:$TRAVIS_BRANCH; @@ -88,12 +88,17 @@ after_success: if [ "${TRAVIS_TAG?}" ]; then git add prod-eu-west/services/client-api/_lupo.auto.tfvars; + git commit -m "Adding lupo git variables for commit tagged ${TRAVIS_TAG?}"; + git push "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git" master; + elif [ "$TRAVIS_PULL_REQUEST" == "true" ]; then + git add stage/services/client-api/_lupo.auto.tfvars; + git commit -m "Adding lupo git variables for pull request #${TRAVIS_PULL_REQUEST}"; + git push "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git" ${TRAVIS_PULL_REQUEST_BRANCH}; else git add stage/services/client-api/_lupo.auto.tfvars; + git commit -m "Adding lupo git variables for latest commit"; + git push "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git" master; fi - - git commit -m "Adding lupo git variables for latest commit"; - git push "https://${TRAVIS_SECURE_TOKEN}@github.com/datacite/mastino.git"; fi notifications: