File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 4
4
$SourceBranch
5
5
)
6
6
7
+ # Getting a created PR. Result object has interface in accordance with article https://docs.github.com/en/rest/reference/pulls#get-a-pull-request
7
8
function Get-PullRequest () {
8
9
return (gh api - X GET repos/ :owner/ :repo/ pulls -F head= " :owner:$SourceBranch " -f state= open -f base= master | ConvertFrom-Json )
9
10
}
Original file line number Diff line number Diff line change
1
+ param (
2
+ [Parameter (Mandatory = $true )]
3
+ [bool ]$IsPRCreated ,
4
+ [Parameter (Mandatory = $true )]
5
+ [string ]$RepoName
6
+ )
7
+
8
+ # Function sends Office 365 connector card to webhook.
9
+ # It requires title and message text displyed in card and theme color used to hignlight card.
10
+ function Send-Notification {
11
+ param (
12
+ [Parameter (Mandatory = $true )]
13
+ [string ]$titleText ,
14
+ [Parameter (Mandatory = $true )]
15
+ [string ]$messageText ,
16
+ [Parameter (Mandatory = $true )]
17
+ [string ]$themeColor
18
+ )
19
+
20
+ $body = [PSCustomObject ]@ {
21
+ title = $titleText
22
+ text = $messageText
23
+ themeColor = $themeColor
24
+ } | ConvertTo-Json
25
+
26
+ Invoke-RestMethod - Uri $ ($env: TEAMS_WEBHOOK ) - Method Post - Body $body - ContentType ' application/json'
27
+ }
28
+
29
+ $wikiLink = " [Wiki](https://mseng.visualstudio.com/AzureDevOps/_wiki/wikis/AzureDevOps.wiki/16150/Localization-update)"
30
+
31
+ if ($IsPRCreated ) {
32
+ $pullRequestLink = " [PR $ ( $env: PR_NUMBER ) ]($ ( $env: PR_LINK ) )"
33
+ $titleText = " Azure Pipelines $RepoName Localization update PR created - ID $ ( $env: PR_NUMBER ) "
34
+ $messageText = " Created $RepoName Localization update PR. Please review and approve/merge $pullRequestLink . Related article in $wikiLink ."
35
+ $themeColor = " #FFFF00"
36
+ }
37
+ else {
38
+ $buildUrl = " $env: SYSTEM_TEAMFOUNDATIONCOLLECTIONURI$env: SYSTEM_TEAMPROJECT /_build/results?buildId=$ ( $env: BUILD_BUILDID ) &_a=summary"
39
+ $buildLink = " [ID $ ( $env: BUILD_BUILDID ) ]($ ( $buildUrl ) )"
40
+ $titleText = " Azure Pipelines $RepoName Localization build failed - ID $ ( $env: BUILD_BUILDID ) "
41
+ $messageText = " Failed to create $RepoName Localization update PR. Please review the results of failed build $buildLink . Related article in $wikiLink ."
42
+ $themeColor = " #FF0000"
43
+ }
44
+
45
+ Send-Notification - titleText $titleText - messageText $messageText - themeColor $themeColor
You can’t perform that action at this time.
0 commit comments