Last active
April 24, 2018 20:31
-
-
Save camsjams/2bc8179afd1e515d9c91c7feaa2c267a to your computer and use it in GitHub Desktop.
CircleCI merge develop message to slack [MIT]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Description: Call this from your CircleCi config after your deploys have been completed | |
# | |
# Set the following variables: | |
# ENVIRONMENT - the name of the environment the deploy went to, ex: "dev", "staging", "production" | |
# CHANNEL - the slack channel you want to post to | |
# WEBHOOK - the slack webhook url you created | |
# PROJECT_NAME - this defaults to looking in a package.json for the "name", customize to your liking and language | |
ENVIRONMENT="test" | |
WEBHOOK="https://hooks.slack.com/services/[your webhook url]" | |
CHANNEL="#[your channel]" | |
PROJECT_NAME=$(sed -nE 's/^\s*"name": "(.*?)",$/\1/p' package.json) | |
MESSAGE="The \`develop\` branch of *$PROJECT_NAME* has been updated by a push from $CIRCLE_USERNAME, new commit hash is \`$CIRCLE_SHA1\`" | |
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"username\": \"MergeBot\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":hammer_and_wrench:\"}" $WEBHOOK | |
# The MIT License (MIT) | |
# Copyright 2018 Cameron Manavian | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment