Skip to content

Instantly share code, notes, and snippets.

@h1bay1
Created April 23, 2018 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h1bay1/f46ecfe44af26fbca4e481adc58bfebf to your computer and use it in GitHub Desktop.
Save h1bay1/f46ecfe44af26fbca4e481adc58bfebf to your computer and use it in GitHub Desktop.
Reporting the changes
Import-Module PSSlack
$success = ":check2:"
$failed = ":x-cross:"
$mergeText = "*Merge Successful*"
$conflictsText = "*Found Conflicts*"
$slackApiKey = '12345'
$slackChannel = '#testchannel'
$branchMatch = "feature/*"
$resultList = @{
"feature/brancha" = $success
"feature/branchb" = $success
"feature/branchc" = $failed
}
$nl = [Environment]::NewLine
$slackMessage = "*Merge Master into branches that match `<$branchMatch>`* $nl"
$lastCommitMessage = git log -1 --pretty=%B
$lastCommitHash = git log --pretty=format:'%H' -n 1
$slackMessage += "The last commit was _<$lastCommitMessage>_ $nl $repoUri/commit/$lastCommitHash $nl"
$groupedResults = $resultList.GetEnumerator() | Group-Object value
$groupedResults | Sort-Object -Descending | ForEach-Object{
if($_.Group[0].value -eq $success){
$slackMessage += $mergeText + $nl
}
else {
$slackMessage += $conflictsText + $nl
}
$_.Group | ForEach-Object {
$message = ""
if($_.Value -eq $success) {
$message = ">$($_.value) _$($_.key)_"
}
else {
$message = ">$($_.value) *$($_.key)*"
}
$slackMessage += "$message $nl"
}
}
Send-SlackMessage -IconEmoji :gitmerge: -Username 'The Great Merger' -Token $slackApiKey -Channel $slackChannel -Parse full -Text $slackMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment