mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-22 12:48:25 +00:00
Disables AWS SQS message to refresh DCOS
This commit is contained in:
parent
7723862530
commit
14d68f40df
@ -16,7 +16,7 @@ before_install:
|
|||||||
- psql -c 'create database crc_test;' -U postgres
|
- psql -c 'create database crc_test;' -U postgres
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install pipenv pytest coverage awscli
|
- pip install pipenv pytest coverage
|
||||||
- export PATH=$PATH:$HOME/.local/bin;
|
- export PATH=$PATH:$HOME/.local/bin;
|
||||||
- pipenv install
|
- pipenv install
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ after_success:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: script
|
provider: script
|
||||||
script: bash deploy.sh
|
script: bash deploy.sh sartography/cr-connect-workflow
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
on:
|
on:
|
||||||
all_branches: true
|
all_branches: true
|
||||||
|
49
deploy.sh
49
deploy.sh
@ -1,44 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/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 () {
|
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() {
|
function branch_to_deploy_group() {
|
||||||
if [[ $1 =~ ^(rrt\/.*)$ ]]; then echo "rrt"; else echo "crconnect" ; fi
|
if [[ $1 =~ ^(rrt\/.*)$ ]]; then echo "rrt"; else echo "crconnect" ; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function branch_to_deploy_stage () {
|
DOCKER_TAG=$(branch_to_tag "$TRAVIS_BRANCH")
|
||||||
if [ "$1" == "master" ]; then echo "production"; else echo "$1" ; fi
|
|
||||||
}
|
|
||||||
|
|
||||||
REPO="sartography/cr-connect-workflow"
|
|
||||||
TAG=$(branch_to_tag "$TRAVIS_BRANCH")
|
|
||||||
|
|
||||||
DEPLOY_APP="backend"
|
|
||||||
DEPLOY_GROUP=$(branch_to_deploy_group "$TRAVIS_BRANCH")
|
DEPLOY_GROUP=$(branch_to_deploy_group "$TRAVIS_BRANCH")
|
||||||
DEPLOY_STAGE=$(branch_to_deploy_stage "$TRAVIS_BRANCH")
|
|
||||||
|
|
||||||
if [ "$DEPLOY_GROUP" == "rrt" ]; then
|
if [ "$DEPLOY_GROUP" == "rrt" ]; then
|
||||||
IFS='/' read -ra ARR <<< "$TRAVIS_BRANCH" # Split branch on '/' character
|
IFS='/' read -ra ARR <<< "$TRAVIS_BRANCH" # Split branch on '/' character
|
||||||
TAG=$(branch_to_tag "rrt_${ARR[1]}")
|
DOCKER_TAG=$(branch_to_tag "rrt_${ARR[1]}")
|
||||||
DEPLOY_STAGE=$(branch_to_deploy_stage "${ARR[1]}")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEPLOY_PATH="$DEPLOY_GROUP/$DEPLOY_STAGE/$DEPLOY_APP"
|
echo "DOCKER_REPO = $DOCKER_REPO"
|
||||||
echo "REPO = $REPO"
|
echo "DOCKER_TAG = $DOCKER_TAG"
|
||||||
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
|
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1
|
||||||
docker build -f Dockerfile -t "$REPO:$TAG" . || exit 1
|
docker build -f Dockerfile -t "$DOCKER_REPO:$DOCKER_TAG" . || exit 1
|
||||||
docker push "$REPO" || exit 1
|
|
||||||
|
|
||||||
# Wait for Docker Hub
|
|
||||||
|
# Push Docker image to Docker Hub
|
||||||
echo "Publishing to Docker Hub..."
|
echo "Publishing to Docker Hub..."
|
||||||
sleep 30
|
docker push "$DOCKER_REPO" || exit 1
|
||||||
|
echo "Done."
|
||||||
# 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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user