Skip to content

Instantly share code, notes, and snippets.

@ijin
Last active December 7, 2018 08:57
Show Gist options
  • Save ijin/7f50694c3bfafce2d54147baf08dd0bf to your computer and use it in GitHub Desktop.
Save ijin/7f50694c3bfafce2d54147baf08dd0bf to your computer and use it in GitHub Desktop.
Deploy to ECR with ecspresso and notify via slack
#!/bin/bash
set -x
export SHA1=`echo ${CIRCLE_SHA1} | cut -c1-7`
export CONFIG_YML=$1
shift
export SERVICE=`./ecspresso deploy --config=$CONFIG_YML --dry-run | grep Service | awk '{print $2}'`
echo "deploying"
time ./ecspresso deploy --config=$CONFIG_YML $@
if [ $? -eq 0 ]; then
export SL_COLOR="good"
export SL_TEXT="Success: Deployed \`$SERVICE\` &lt;${CIRCLE_BRANCH}&gt; (<${CIRCLE_COMPARE_URL}|${SHA1}>) by ${CIRCLE_USERNAME} !!"
export SL_ICON="https://www.shippable.com/assets/images/logos/amazon-ecs.jpg"
export EXIT=0
else
export SL_COLOR="danger"
export SL_TEXT="Failure: Deploying \`$SERVICE\` &lt;${CIRCLE_BRANCH}&gt; (<${CIRCLE_COMPARE_URL}|${SHA1}>) by ${CIRCLE_USERNAME} !!"
export SL_ICON="https://www.shippable.com/assets/images/logos/amazon-ecs.jpg"
export EXIT=1
fi
curl -X POST --data-urlencode 'payload={"username": "ECS ('"$CIRCLE_PROJECT_REPONAME"')", "icon_url": "'"$SL_ICON"'", "channel": "'"${CHANNEL:-#test}"'", "attachments": [{ "color": "'"$SL_COLOR"'", "text": "'"$SL_TEXT"'", "mrkdwn_in": ["text"] }] }' https://hooks.slack.com/services/${SLACK_HOOK}
exit $EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment