diff --git a/.circleci/config.yml b/.circleci/config.yml index e6a76e7f5ed..30e7194d6c8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -212,10 +212,12 @@ jobs: docker push scalableminds/webknossos-dev:$CIRCLE_BRANCH fi docker logout - - run: name: Report coverage command: .circleci/not-on-master.sh docker-compose run base yarn coverage + - run: + name: Send Slack notification (master only) + command: .circleci/slack-notification.sh nightly: docker: diff --git a/.circleci/slack-notification.sh b/.circleci/slack-notification.sh new file mode 100755 index 00000000000..dfd4b1ff73c --- /dev/null +++ b/.circleci/slack-notification.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +if [ "${CIRCLE_BRANCH}" == "master" ] ; then + author=${CIRCLE_USERNAME} + author=${author/fm3/<@florian>} + author=${author/jstriebel/<@jonathan>} + author=${author/daniel-wer/<@daniel>} + author=${author/georgwiese/<@georg>} + author=${author/hotzenklotz/<@tom>} + author=${author/jfrohnhofen/<@johannes>} + author=${author/MichaelBuessemeyer/<@michael>} + author=${author/normanrz/<@norman>} + author=${author/philippotto/<@philipp>} + author=${author/rschwanhold/<@robert>} + author=${author/tmbo/<@tmbo>} + author=${author/valentin-pinkau/<@valentin>} + channel="webknossos-bots" + commitmsg=$(git log --format=%s -n 1) + pullregex="(.*)#([0-9]+)(.*)" + while [[ $commitmsg =~ $pullregex ]] + do + commitmsg="${BASH_REMATCH[1]}#${BASH_REMATCH[3]}" + done + buildlink="" + mesg="${author} your ${CIRCLE_BRANCH} build ${buildlink} “${commitmsg}” is almost finished." + user="circleci-notify" + token="${SLACK_NOTIFY_TOKEN:-}" + res=$(curl -s \ + -X POST \ + -d "token=${token}" \ + -d "channel=${channel}" \ + -d "text=${mesg}" \ + -d "username=${user}" \ + -d "icon_url=https://a.slack-edge.com/41b0a/img/plugins/circleci/service_48.png" \ + https://slack.com/api/chat.postMessage + ) + if [[ "$(echo ${res} | jq '.ok')" == "false" ]]; then + echo "[WARN] Error sending Slack notification: $(echo ${res} | jq -r '.error')." + fi + echo "[INFO] Sent Slack notification to ${channel}." +fi