Fails build if any deploy step fails

This commit is contained in:
Aaron Louie 2020-05-07 15:55:03 -04:00
parent 6a2d9b5080
commit 90197c28cd
2 changed files with 7 additions and 7 deletions

View File

@ -14,7 +14,7 @@ deploy:
skip_cleanup: true
on:
all_branches: true
# condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$
condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$
notifications:
email:

View File

@ -1,16 +1,16 @@
#!/bin/bash
# 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 || exit 1
APP="db"
REPO="sartography/cr-connect-$APP"
TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH" ; fi)
COMMIT=${TRAVIS_COMMIT::8}
docker build -f Dockerfile -t "$REPO:$COMMIT" --build-arg GIT_COMMIT="$REPO:$COMMIT" .
docker tag "$REPO:$COMMIT" "$REPO:$TAG"
docker tag "$REPO:$COMMIT" "$REPO:travis-$TRAVIS_BUILD_NUMBER"
docker push "$REPO"
docker build -f Dockerfile -t "$REPO:$COMMIT" --build-arg GIT_COMMIT="$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
# Wait for Docker Hub
echo "Publishing to Docker Hub..."
@ -18,4 +18,4 @@ 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"
aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "crconnect/$TRAVIS_BRANCH/$APP" || exit 1