From 0200e0bfae42e582b51ab87c024ea2679ec6fbec Mon Sep 17 00:00:00 2001 From: Amir Moualem Date: Wed, 4 Sep 2019 16:46:14 +0300 Subject: [PATCH 1/4] chore: docker login on the "tag and push" stage of "merge to staging" job --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4690685d4..87a089857 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,8 @@ jobs: name: Test and Build - stage: tag-and-push if: branch = staging AND type = push - script: npx semantic-release && + script: docker login --username ${DOCKERHUB_USER} --password ${DOCKERHUB_PASSWORD} && + npx semantic-release && NEW_VERSION=`cat ./package.json | jq -r '.version'` && ./scripts/approve-image.sh $NEW_VERSION || ( ./scripts/slack-notify-failure.sh "staging-release" && false ) From 4d4f505755cf0b1395949b119765ade03f2d1a23 Mon Sep 17 00:00:00 2001 From: Amir Moualem Date: Wed, 4 Sep 2019 16:53:55 +0300 Subject: [PATCH 2/4] chore: chain approve-image commands so they continue only if the previous one succeeds --- scripts/approve-image.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/approve-image.sh b/scripts/approve-image.sh index 654464b5d..137557990 100755 --- a/scripts/approve-image.sh +++ b/scripts/approve-image.sh @@ -9,8 +9,8 @@ else IMAGE_NAME_CANDIDATE=snyk/kubernetes-monitor:staging-candidate IMAGE_NAME_APPROVED=snyk/kubernetes-monitor:${1}-approved - docker pull ${IMAGE_NAME_CANDIDATE} - docker tag ${IMAGE_NAME_CANDIDATE} ${IMAGE_NAME_APPROVED} - docker push ${IMAGE_NAME_APPROVED} + docker pull ${IMAGE_NAME_CANDIDATE} && + docker tag ${IMAGE_NAME_CANDIDATE} ${IMAGE_NAME_APPROVED} && + docker push ${IMAGE_NAME_APPROVED} && ./scripts/slack-notify-push.sh ${IMAGE_NAME_APPROVED} fi From 13e0d8a877bf6d52f4a1c8b09215565909d67bb9 Mon Sep 17 00:00:00 2001 From: Amir Moualem Date: Wed, 4 Sep 2019 16:54:48 +0300 Subject: [PATCH 3/4] chore: notify on successful staging merge that caused no rem-rel --- scripts/approve-image.sh | 1 + scripts/slack-notify-success-no-release.sh | 2 ++ 2 files changed, 3 insertions(+) create mode 100755 scripts/slack-notify-success-no-release.sh diff --git a/scripts/approve-image.sh b/scripts/approve-image.sh index 137557990..8ade0ab80 100755 --- a/scripts/approve-image.sh +++ b/scripts/approve-image.sh @@ -5,6 +5,7 @@ # then it would be null if [ $1 == "null" ]; then echo Semantic-Release did not create a new version, not pushing a new approved image + ./scripts/slack-notify-success-no-release.sh else IMAGE_NAME_CANDIDATE=snyk/kubernetes-monitor:staging-candidate IMAGE_NAME_APPROVED=snyk/kubernetes-monitor:${1}-approved diff --git a/scripts/slack-notify-success-no-release.sh b/scripts/slack-notify-success-no-release.sh new file mode 100755 index 000000000..e74a3e371 --- /dev/null +++ b/scripts/slack-notify-success-no-release.sh @@ -0,0 +1,2 @@ +#! /bin/bash +curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: $TRAVIS_BUILD_WEB_URL", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Successful `staging` merge, but no semantic-release occurring :egg_fancy:"}]}' $SLACK_WEBHOOK From 2e63a92d8b0e3d416c158f4a2a70511be57edc13 Mon Sep 17 00:00:00 2001 From: Amir Moualem Date: Wed, 4 Sep 2019 16:55:09 +0300 Subject: [PATCH 4/4] feat: trigger semantic release