forked from Azure/Azure-Sentinel
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (73 loc) · 3.03 KB
/
arm-ttk-validations.yaml
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
81
82
83
84
name: Arm-ttk Validations
on: [pull_request]
jobs:
run-arm-ttk:
runs-on: ubuntu-latest
outputs:
solutionName: ${{ steps.step1.outputs.solutionName }}
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }}
createUiChanged: ${{ steps.step1.outputs.createUiChanged }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- shell: pwsh
id: step1
name: Identify Changes in PR
run: |
$diff = git diff --diff-filter=d --name-only HEAD^ HEAD
Write-Host "List of files in PR: $diff"
$hasmainTemplateChanged = $false
$hasCreateUiDefinitionTemplateChanged = $false
$isChangeInSolutionsFolder = [bool]($diff | Where-Object {$_ -like 'Solutions/*'})
if (!$isChangeInSolutionsFolder)
{
Write-Host "Skipping as change is not in Solutions folder!"
exit 0
}
$requiredFiles = @("mainTemplate.json", "createUiDefinition.json")
$filteredFiles = $diff | Where-Object {$_ -match ($requiredFiles -Join "|")}
Write-Host "Filtered Files $filteredFiles"
if ($filteredFiles.Count -gt 0)
{
$mainTemplateValue = $filteredFiles -match "mainTemplate.json"
$createUiValue = $filteredFiles -match "createUiDefinition.json"
if ($mainTemplateValue)
{
$hasmainTemplateChanged = $true
}
if ($createUiValue)
{
$hasCreateUiDefinitionTemplateChanged = $true
}
if ($filteredFiles.Count -eq 1)
{
$packageIndex = $filteredFiles.IndexOf("/Package")
$sName = $filteredFiles.SubString(10, $packageIndex - 10)
}
else
{
$packageIndex = $filteredFiles[0].IndexOf("/Package")
$sName = $filteredFiles[0].SubString(10, $packageIndex - 10)
}
Write-Host "SolutionName: $sName"
}
Write-Output "::set-output name=solutionName::$sName"
Write-Output "::set-output name=mainTemplateChanged::$hasmainTemplateChanged"
Write-Output "::set-output name=createUiChanged::$hasCreateUiDefinitionTemplateChanged"
- uses: docker/build-push-action@v2
id: publishGithubPackage
name: Run ARM-TTK
if: ${{ success() && steps.step1.outcome == 'success' && steps.step1.outputs.solutionName != '' && (steps.step1.outputs.mainTemplateChanged == 'true' || steps.step1.outputs.createUiChanged == 'true') }}
env:
SolutionName: ${{ steps.step1.outputs.solutionName }}
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }}
createUiChanged: ${{ steps.step1.outputs.createUiChanged }}
with:
context: .
file: ./.github/actions/Dockerfile
push: false
build-args: |
SolutionName
mainTemplateChanged
createUiChanged