2020-02-05 20:53:52 +00:00
|
|
|
#!/bin/bash
|
2020-04-03 13:53:47 +00:00
|
|
|
|
2020-05-14 01:15:13 +00:00
|
|
|
function branch_to_tag () {
|
|
|
|
if [ "$1" == "latest" ]; then echo "production"; 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
|
|
|
|
}
|
|
|
|
|
2020-05-07 14:15:14 +00:00
|
|
|
REPO="sartography/cr-connect-workflow"
|
2020-05-14 01:15:13 +00:00
|
|
|
TAG=$(branch_to_tag "$TRAVIS_BRANCH")
|
2020-05-07 17:49:17 +00:00
|
|
|
|
2020-05-14 01:15:13 +00:00
|
|
|
DEPLOY_APP="backend"
|
|
|
|
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]}")
|
|
|
|
fi
|
|
|
|
|
|
|
|
DEPLOY_PATH="$DEPLOY_GROUP/$DEPLOY_STAGE/$DEPLOY_APP"
|
|
|
|
echo "REPO = $REPO"
|
|
|
|
echo "TAG = $TAG"
|
|
|
|
echo "DEPLOY_PATH = $DEPLOY_PATH"
|
|
|
|
|
|
|
|
# Build and push Docker image to Docker Hub
|
|
|
|
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1
|
2020-05-14 12:52:05 +00:00
|
|
|
docker build -f Dockerfile -t "$REPO:$TAG" . || exit 1
|
2020-05-07 14:47:24 +00:00
|
|
|
docker push "$REPO" || exit 1
|
2020-04-03 13:53:47 +00:00
|
|
|
|
2020-04-23 18:47:07 +00:00
|
|
|
# Wait for Docker Hub
|
|
|
|
echo "Publishing to Docker Hub..."
|
|
|
|
sleep 30
|
|
|
|
|
2020-05-14 01:15:13 +00:00
|
|
|
# Notify UVA DCOS that Docker image has been updated
|
2020-04-23 18:47:07 +00:00
|
|
|
echo "Refreshing DC/OS..."
|
2020-05-14 01:15:13 +00:00
|
|
|
aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "$DEPLOY_PATH" || exit 1
|