Add a new incoming webhook to Slack. This will give you a webhook URL complete with a token. You should also select a channel to default post to.
Last active
March 14, 2018 16:13
-
-
Save neutraltone/7b384eedbc6dc3bd66107b3378daf39f to your computer and use it in GitHub Desktop.
Slack Deploy Message Script
This file contains 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
# Post to Slack | |
SHA=$(git rev-parse --verify HEAD) | |
MSG=$(git log -1 --pretty=format:'%s') | |
AUTHOR=$(git log -1 --pretty=format:'%an') | |
BRANCH=$(git branch | grep \* | cut -d ' ' -f2) | |
FALLBACKMSG="https://github.com/<USERNAME>/<REPO>/commit/$SHA deployed to <WEBSITE-URL>" | |
URLMSG="<https://github.com/<USERNAME>/<REPO>/commit/$SHA|$MSG>" | |
SHAMSG="<https://github.com/<USERNAME>/<REPO>/commit/$SHA|$SHA>" | |
curl -X POST --data-urlencode 'payload={"username": "Forge", "icon_emoji": ":shipit:", "attachments": [{"fallback": "'"$FALLBACKMSG"'", "color": "good", "fields": [{"title": "Deployed", "value": "'"$URLMSG"'", "short": true},{"title": "Author", "value": "'"$AUTHOR"'", "short": true},{"title": "Branch", "value": "'"$BRANCH"'", "short": true},{"title": "Website", "value": "<WEBSITE-URL>", "short": true},{"title": "SHA", "value": "'"$SHAMSG"'"}]}]}' <WEBHOOK-URL> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment