Skip to content

Instantly share code, notes, and snippets.

@ifnull
Last active November 1, 2021 17:35
Show Gist options
  • Save ifnull/b83aadfc2996a9b217c0956b16624b97 to your computer and use it in GitHub Desktop.
Save ifnull/b83aadfc2996a9b217c0956b16624b97 to your computer and use it in GitHub Desktop.

Revisions

  1. Daniel Smith revised this gist Nov 1, 2021. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions post-merge
    Original file line number Diff line number Diff line change
    @@ -13,9 +13,7 @@ GIT_HEAD_SHORT=${GIT_HEAD:0:9}

    # Create message
    GIT_MESSAGE="Deploy ($GIT_ORIG_HEAD_SHORT..$GIT_HEAD_SHORT):\n"
    GIT_MESSAGE+=\`\`\`"$(git log --graph --date=short ORIG_HEAD..HEAD)"\`\`\`

    #echo $GIT_MESSAGE
    GIT_MESSAGE+=\`\`\`"$(git log --pretty=format:'%h %cr %cn %Cgreen%s%Creset' ORIG_HEAD..HEAD)"\`\`\`

    # Send to Slack
    curl -s -X POST --data "payload={ \"username\": \"${SLACK_USERNAME}\", \"text\": \"${GIT_MESSAGE}\"}" ${SLACK_WEBHOOK_URL} > /dev/null
  2. Daniel Smith created this gist Nov 1, 2021.
    21 changes: 21 additions & 0 deletions post-merge
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/sh
    # WARNING: Putting your git repo in your web root can be dangerous.

    SLACK_WEBHOOK_URL=$(git config --get hooks.slack.deploy-webhook-url)
    SLACK_USERNAME="Git Deploy Bot (Develop)"

    REPO_PATH="$(dirname ${BASH_SOURCE[0]})/.."
    GIT_ORIG_HEAD=$(git rev-parse ORIG_HEAD | awk '{print $1}')
    GIT_HEAD=$(git rev-parse HEAD | awk '{print $1}')

    GIT_ORIG_HEAD_SHORT=${GIT_ORIG_HEAD:0:9}
    GIT_HEAD_SHORT=${GIT_HEAD:0:9}

    # Create message
    GIT_MESSAGE="Deploy ($GIT_ORIG_HEAD_SHORT..$GIT_HEAD_SHORT):\n"
    GIT_MESSAGE+=\`\`\`"$(git log --graph --date=short ORIG_HEAD..HEAD)"\`\`\`

    #echo $GIT_MESSAGE

    # Send to Slack
    curl -s -X POST --data "payload={ \"username\": \"${SLACK_USERNAME}\", \"text\": \"${GIT_MESSAGE}\"}" ${SLACK_WEBHOOK_URL} > /dev/null
    2 changes: 2 additions & 0 deletions setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # Create an Incoming Webhooks intengration here to get a webhook URL: https://***.slack.com/apps/manage/custom-integrations
    git config hooks.slack.deploy-webhook-url 'https://hooks.slack.com/services/*****/*****/*****'