forked from nanoframework/nf-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file-checks.yml
49 lines (39 loc) · 1.61 KB
/
file-checks.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
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
steps:
- task: PowerShell@2
condition: >-
and(
succeeded(),
eq(variables['StartReleaseCandidate'], false),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
)
displayName: File checks
inputs:
targetType: 'inline'
script: |
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))"
$checksFailed = $false
if($env:System_PullRequest_PullRequestId -ne $null)
{
# get files changed in PR, if this is a PR
$commit = Invoke-RestMethod -Uri "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber/files" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET
# filter removed files
$files = $commit.where{$_.status -ne 'removed'}
# get file names only
$files = $files | % {$_.filename}
############################
# check for app.config files
$appConfigFiles = ($files.where{$_.EndsWith('app.config')})
if($appConfigFiles.Count)
{
"Found app.config file(s) in the project(s)" | Write-Host -ForegroundColor Red
$appConfigFiles | Write-Host
$checksFailed = $true
}
}
# global check for checks failure
if($checksFailed)
{
exit 1
}