Moves deploy logic into a script like the other repos

This commit is contained in:
Aaron Louie 2020-05-06 17:18:34 -04:00
parent c3771d4dfc
commit 7ce45c55bd
2 changed files with 30 additions and 16 deletions

View File

@ -7,23 +7,18 @@ env:
global: global:
- COMMIT=${TRAVIS_COMMIT::8} - COMMIT=${TRAVIS_COMMIT::8}
before_install:
- sudo pip install --upgrade pip
- pip install --user awscli
- export PATH=$PATH:$HOME/.local/bin
- echo $DOCKER_TOKEN | docker login -u "$DOCKER_USERNAME" --password-stdin
install: install:
- export REPO=sartography/cr-connect-db - pip install pipenv pytest coverage awscli
- export TAG=`if [$TRAVIS_BRANCH == "master"]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi` - export PATH=$PATH:$HOME/.local/bin;
- docker build --build-arg GIT_COMMIT="$REPO:$COMMIT" -f Dockerfile -t $REPO:$COMMIT . - pipenv install
- echo "REPO:TAG = $REPO:$TAG"
- echo "$REPO:$COMMIT = $REPO:$TAG" deploy:
- echo "$REPO:travis-$TRAVIS_BUILD_NUMBER" provider: script
- docker tag $REPO:$COMMIT $REPO:$TAG script: bash deploy.sh
- docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER skip_cleanup: true
- docker push $REPO on:
- aws sqs send-message --region '$AWS_DEFAULT_REGION' --queue-url '$AWS_SQS_URL' --message-body 'crconnect/$TRAVIS_BRANCH/db' all_branches: true
condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$
notifications: notifications:
email: email:

19
deploy.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Build and push Docker image to Docker Hub
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
APP="db"
REPO="sartography/cr-connect-$APP";
TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH" ; fi;)
docker build --build-arg GIT_COMMIT="$REPO:$COMMIT" -f Dockerfile -t "$REPO:$COMMIT" .;
docker tag "$REPO:$COMMIT" "$REPO:$TAG";
docker tag "$REPO:$COMMIT" "$REPO:travis-$TRAVIS_BUILD_NUMBER";
docker push "$REPO";
# Wait for 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 "crconnect/$TRAVIS_BRANCH/$APP";