Created
April 23, 2018 21:22
-
-
Save h1bay1/f46ecfe44af26fbca4e481adc58bfebf to your computer and use it in GitHub Desktop.
Reporting the changes
This file contains hidden or 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
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