Merge pull request #36 from sartography/chore/github_branches_to_docker_tags
Builds and deploys Docker image if build passes on testing, staging, …
This commit is contained in:
commit
f4e293e8fa
|
@ -36,7 +36,8 @@ deploy:
|
||||||
script: bash deploy.sh
|
script: bash deploy.sh
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
on:
|
on:
|
||||||
branch: master
|
all_branches: true
|
||||||
|
condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
|
14
deploy.sh
14
deploy.sh
|
@ -2,13 +2,19 @@
|
||||||
|
|
||||||
# Build and push Docker image to Docker Hub
|
# Build and push Docker image to Docker Hub
|
||||||
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||||
docker build --no-cache -t sartography/cr-connect-backend:latest . || exit 1;
|
REPO="sartography/cr-connect-workflow"
|
||||||
docker push sartography/cr-connect-backend:latest || exit 1;
|
TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH" ; fi)
|
||||||
|
COMMIT=${$TRAVIS_COMMIT::8}
|
||||||
|
docker build -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
|
# Wait for Docker Hub
|
||||||
echo "Publishing to Docker Hub..."
|
echo "Publishing to Docker Hub..."
|
||||||
sleep 30
|
sleep 30
|
||||||
|
|
||||||
# Notify UVA DCOS that Docker image has been updated
|
# Notify DC/OS that Docker image has been updated
|
||||||
echo "Refreshing DC/OS..."
|
echo "Refreshing DC/OS..."
|
||||||
aws sqs send-message --queue-url 'https://queue.amazonaws.com/474683445819/dcos-refresh' --message-body 'crconnect/backend' || exit 1;
|
STAGE=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "production"; else echo "$TRAVIS_BRANCH" ; fi)
|
||||||
|
aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "crconnect/$STAGE/backend"
|
||||||
|
|
Loading…
Reference in New Issue