Skip to content

Commit

Permalink
Merge pull request #109 from snyk/chore/refactors
Browse files Browse the repository at this point in the history
Chore/refactors
  • Loading branch information
Amir Moualem authored Sep 4, 2019
2 parents 0635879 + 2e63a92 commit 7349d46
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
7 changes: 4 additions & 3 deletions scripts/approve-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
# 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

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
2 changes: 2 additions & 0 deletions scripts/slack-notify-success-no-release.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7349d46

Please sign in to comment.