Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sync to S3 and notify via Slack
set -x
export S3=`echo $1`
export SHA1=`echo ${CIRCLE_SHA1} | cut -c1-7`
export ENV=`echo $1 | rev | cut -d \- -f1 | rev`
aws --region $REGION s3 sync . s3://$S3/ --exclude 'circle.yml' --exclude '.*' --exclude '*.swp' --exclude 's3*.sh' --delete
if [ $? -eq 0 ]; then
export SL_COLOR="good"
export SL_TEXT="Sync success: $S3 - ${CIRCLE_BRANCH} (<${CIRCLE_COMPARE_URL}|${SHA1}>) by ${CIRCLE_USERNAME} !!"
export SL_ICON=""
export EXIT=0
export SL_COLOR="danger"
export SL_TEXT="Sync failure: $S3 - ${CIRCLE_BRANCH} (<${CIRCLE_COMPARE_URL}|${SHA1}>) by ${CIRCLE_USERNAME} !!"
export SL_ICON=""
export EXIT=1
curl -X POST --data-urlencode 'payload={"username": "S3 ('"$CIRCLE_PROJECT_REPONAME"')", "icon_url": "'"$SL_ICON"'", "channel": "'"${CHANNEL:-#test}"'", "attachments": [{ "color": "'"$SL_COLOR"'", "text": "'"$SL_TEXT"'", "mrkdwn_in": ["text"] }] }'${SLACK_HOOK}
exit $EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment