-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathvalidate.yml
80 lines (64 loc) · 2.03 KB
/
validate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
name: "AzOps - Validate"
#
# Triggers
# Automated triggers are configured via Branch Policies
# within Azure Repos. It's also recommended to manually
# disable CI triggers with overrides.
#
trigger: none
variables:
#
# Shared variables
# Include shared variables from the 'vars.yml' file
# to not have to repeat them in every pipeline.
#
- template: .templates/vars.yml
jobs:
- job: validate
condition: ne(variables['system.pullRequest.sourceBranch'], 'refs/heads/automated')
#
# Validate
#
displayName: "Validate"
pool:
vmImage: "ubuntu-20.04"
steps:
#
# Shared steps
# Include shared steps from the 'shared.yml' file
# to not have to repeat them in every pipeline.
#
- template: .templates/sharedSteps.yml
#
# Validate
# Run what-if deployment on any templates changed
# in the last commit
#
- template: .templates/validate-deploy.yml
parameters:
deploy: false
#
# Results
# Post results as a comment to the pull request.
#
- task: PowerShell@2
displayName: 'Results'
condition: eq(variables['Build.Reason'], 'PullRequest')
inputs:
targetType: "inline"
script: |
if (Test-Path "/tmp/OUTPUT.md") {
$uri = "$(System.CollectionUri)/$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullRequests/$(System.PullRequest.PullRequestId)/threads?api-version=6.0"
Invoke-RestMethod `
-Method Post `
-ContentType "application/json;charset=utf-8" `
-Headers @{ "Authorization" = "Bearer $(System.AccessToken)" } `
-Body (@{
"comments" = @(
@{ "parentCommentId" = 0; "content" = "$(Get-Content -Path /tmp/OUTPUT.md -Raw)"; "commentType" = 1 }
)
"status" = 1
} | ConvertTo-Json) `
-Uri $uri
}