forked from StefanScherer/dockerfiles-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
41 lines (35 loc) · 964 Bytes
/
build.ps1
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
$ErrorActionPreference = 'Stop';
$files = ""
Write-Host Starting build
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
Write-Host Pull request $env:APPVEYOR_PULL_REQUEST_NUMBER
$files = $(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD main))
} else {
Write-Host Branch $env:APPVEYOR_REPO_BRANCH
$files = $(git diff --name-only HEAD~1)
}
Write-Host Changed files:
$dirs = @{}
$files | ForEach-Object {
Write-Host $_
$dir = $_ -replace "\/[^\/]+$", ""
$dir = $dir -replace "/", "\"
if (Test-Path "$dir\build.ps1") {
Write-Host "Storing $dir for build"
$dirs.Set_Item($dir, 1)
} else {
$dir = $dir -replace "\\[^\\]+$", ""
if (Test-Path "$dir\build.ps1") {
Write-Host "Storing $dir for build"
$dirs.Set_Item($dir, 1)
}
}
}
$dirs.GetEnumerator() | Sort-Object Name | ForEach-Object {
$dir = $_.Name
Write-Host Building in directory $dir
pushd $dir
.\build.ps1
popd
}
docker images