From e9f5b43e1f4e6894582028bf27d1cd8dc8fd6321 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Tue, 16 Jun 2020 11:13:00 -0400 Subject: [PATCH 1/2] Disables AWS SQS message to refresh DCOS --- .travis.yml | 12 +----------- deploy.sh | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e9b25d..a524846 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,17 +4,7 @@ services: - docker install: - - sudo pip install --upgrade pip - - pip install --user awscli - - export PATH=$PATH:$HOME/.local/bin - -deploy: - provider: script - script: bash deploy.sh - skip_cleanup: true - on: - all_branches: true - condition: $TRAVIS_BRANCH =~ ^(dev|testing|demo|training|staging|master|rrt\/.*)$ + - bash deploy.sh sartography/cr-connect-db notifications: email: diff --git a/deploy.sh b/deploy.sh index f47ec5b..04e3e81 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,44 +1,45 @@ #!/bin/bash +######################################################################### +# Builds the Docker image for the current git branch on Travis CI and +# publishes it to Docker Hub. +# +# Parameters: +# $1: Docker Hub repository to publish to +# +# Required environment variables (place in Settings menu on Travis CI): +# $DOCKER_USERNAME: Docker Hub username +# $DOCKER_TOKEN: Docker Hub access token +######################################################################### + +echo 'Building Docker image...' +DOCKER_REPO="$1" + function branch_to_tag () { - if [ "$1" == "latest" ]; then echo "production"; else echo "$1" ; fi + if [ "$1" == "master" ]; then echo "latest"; else echo "$1" ; fi } function branch_to_deploy_group() { if [[ $1 =~ ^(rrt\/.*)$ ]]; then echo "rrt"; else echo "crconnect" ; fi } -function branch_to_deploy_stage () { - if [ "$1" == "master" ]; then echo "production"; else echo "$1" ; fi -} +DOCKER_TAG=$(branch_to_tag "$TRAVIS_BRANCH") -REPO="sartography/cr-connect-db" -TAG=$(branch_to_tag "$TRAVIS_BRANCH") - -DEPLOY_APP="db" DEPLOY_GROUP=$(branch_to_deploy_group "$TRAVIS_BRANCH") -DEPLOY_STAGE=$(branch_to_deploy_stage "$TRAVIS_BRANCH") if [ "$DEPLOY_GROUP" == "rrt" ]; then IFS='/' read -ra ARR <<< "$TRAVIS_BRANCH" # Split branch on '/' character - TAG=$(branch_to_tag "rrt_${ARR[1]}") - DEPLOY_STAGE=$(branch_to_deploy_stage "${ARR[1]}") + DOCKER_TAG=$(branch_to_tag "rrt_${ARR[1]}") fi -DEPLOY_PATH="$DEPLOY_GROUP/$DEPLOY_STAGE/$DEPLOY_APP" -echo "REPO = $REPO" -echo "TAG = $TAG" -echo "DEPLOY_PATH = $DEPLOY_PATH" +echo "DOCKER_REPO = $DOCKER_REPO" +echo "DOCKER_TAG = $DOCKER_TAG" -# Build and push Docker image to Docker Hub echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1 -docker build -f Dockerfile -t "$REPO:$TAG" . || exit 1 -docker push "$REPO" || exit 1 +docker build -f Dockerfile -t "$DOCKER_REPO:$DOCKER_TAG" . || exit 1 -# Wait for Docker Hub + +# Push Docker image to Docker Hub echo "Publishing to Docker Hub..." -sleep 30 - -# Notify UVA DCOS that Docker image has been updated -echo "Refreshing DC/OS..." -aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "$DEPLOY_PATH" || exit 1 +docker push "$DOCKER_REPO" || exit 1 +echo "Done." From 804f3f1b8d6d44ab322c09199b74cfb4f44946b5 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Tue, 16 Jun 2020 12:23:26 -0400 Subject: [PATCH 2/2] Skips install step. Moves deploy to script step --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a524846..3efe029 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,9 @@ language: bash services: - docker -install: +install: skip + +script: - bash deploy.sh sartography/cr-connect-db notifications: @@ -12,4 +14,3 @@ notifications: on_failure: always recipients: - dan@sartography.com -