2020-02-05 20:53:52 +00:00
|
|
|
#!/bin/bash
|
2020-04-03 13:53:47 +00:00
|
|
|
|
|
|
|
# Build and push Docker image to Docker Hub
|
2020-05-07 14:47:24 +00:00
|
|
|
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1
|
2020-05-07 14:15:14 +00:00
|
|
|
REPO="sartography/cr-connect-workflow"
|
|
|
|
TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH" ; fi)
|
2020-05-07 18:24:15 +00:00
|
|
|
COMMIT=${TRAVIS_COMMIT::8}
|
2020-05-07 17:49:17 +00:00
|
|
|
|
2020-05-07 14:47:24 +00:00
|
|
|
docker build -f Dockerfile -t "$REPO:$COMMIT" . || exit 1
|
|
|
|
docker tag "$REPO:$COMMIT" "$REPO:$TAG" || exit 1
|
|
|
|
docker tag "$REPO:$COMMIT" "$REPO:travis-$TRAVIS_BUILD_NUMBER" || exit 1
|
|
|
|
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-07 14:15:14 +00:00
|
|
|
# Notify DC/OS that Docker image has been updated
|
2020-04-23 18:47:07 +00:00
|
|
|
echo "Refreshing DC/OS..."
|
2020-05-07 14:15:14 +00:00
|
|
|
STAGE=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "production"; else echo "$TRAVIS_BRANCH" ; fi)
|
2020-05-07 17:49:17 +00:00
|
|
|
echo "STAGE = $STAGE"
|
2020-05-07 14:47:24 +00:00
|
|
|
aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "crconnect/$STAGE/backend" || exit 1
|