From 1664645555385604b543aa3cfa3ce454208fa27c Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Fri, 8 May 2020 11:42:21 -0400 Subject: [PATCH] Tags Docker image with branch, commit, and Travis build number. Deploys to appropriate DC/OS stage after successful Docker push. --- .travis.yml | 3 ++- deploy.sh | 30 ++++++++++++++++++------------ package-lock.json | 6 +++--- package.json | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 260f90c..fff4d82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,8 @@ deploy: script: bash ./deploy.sh skip_cleanup: true on: - branch: master + all_branches: true + condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$ notifications: email: diff --git a/deploy.sh b/deploy.sh index 012097e..d79a7f6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,16 +1,22 @@ #!/bin/bash -# Install AWS CLI -pip install --user awscli; -export PATH=$PATH:$HOME/.local/bin; - # Build and push Docker image to Docker Hub -echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin; -docker build \ - --build-arg build_config="$DEPLOY_BUILD_CONFIG" \ - --no-cache -t sartography/cr-connect-bpmn:latest . \ - || exit 1; -docker push sartography/cr-connect-bpmn:latest || exit 1; +echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1 +REPO="sartography/cr-connect-bpmn" +TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH" ; fi) +COMMIT=${TRAVIS_COMMIT::8} -# Notify UVA DCOS that Docker image has been updated -aws sqs send-message --queue-url 'https://queue.amazonaws.com/474683445819/dcos-refresh' --message-body 'crconnect/bpmn' || exit 1; +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 + +# Wait for Docker Hub +echo "Publishing to Docker Hub..." +sleep 30 + +# Notify DC/OS that Docker image has been updated +echo "Refreshing DC/OS..." +STAGE=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "production"; else echo "$TRAVIS_BRANCH" ; fi) +echo "STAGE = $STAGE" +aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "crconnect/$STAGE/bpmn" || exit 1 diff --git a/package-lock.json b/package-lock.json index 7ff1b31..0c4233f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12291,9 +12291,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sartography-workflow-lib": { - "version": "0.0.137", - "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.137.tgz", - "integrity": "sha512-qfmhuNXZNyxu3BiCNNmbXXTHj7UOPFSUVqx2RJDUoYC0o+xxPKxNysC6M1MizGyQciiXFWd8xlnQBOixbHQHeQ==" + "version": "0.0.147", + "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.147.tgz", + "integrity": "sha512-CaueuOhiZgYmp4NjPsKt9zad3yAqzT/ibnIqC+sIQHt99UKmSzsaFuuDN2l5ux4E/Xe4D33Ew6djXtrgcGROTw==" }, "sass": { "version": "1.23.3", diff --git a/package.json b/package.json index 478e5ac..4b01807 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "ngx-file-drop": "^8.0.8", "ngx-markdown": "^9.0.0", "rxjs": "~6.5.4", - "sartography-workflow-lib": "^0.0.137", + "sartography-workflow-lib": "^0.0.147", "tslib": "^1.11.1", "uuid": "^7.0.2", "zone.js": "^0.10.3"