forked from StefanScherer/dockerfiles-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.ps1
59 lines (51 loc) · 1.49 KB
/
deploy.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$ErrorActionPreference = 'Stop';
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER -Or ! $env:APPVEYOR_REPO_BRANCH.Equals("main")) {
Write-Host Nothing to deploy.
Exit 0
}
$files = ""
Write-Host Starting deploy
# "$env:DOCKER_PASS" | docker login --username "$env:DOCKER_USER" --password-stdin
# docker login with the old config.json style that is needed for manifest-tool
$auth =[System.Text.Encoding]::UTF8.GetBytes("$($env:DOCKER_USER):$($env:DOCKER_PASS)")
$auth64 = [Convert]::ToBase64String($auth)
@"
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "$auth64"
}
}
}
"@ | Out-File -Encoding Ascii ~/.docker/config.json
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\push.ps1") {
Write-Host "Storing $dir for deployment"
$dirs.Set_Item($dir, 1)
} else {
$dir = $dir -replace "\\[^\\]+$", ""
if (Test-Path "$dir\push.ps1") {
Write-Host "Storing $dir for deployment"
$dirs.Set_Item($dir, 1)
}
}
}
$dirs.GetEnumerator() | Sort-Object Name | ForEach-Object {
$dir = $_.Name
Write-Host Building in directory $dir
pushd $dir
.\push.ps1
popd
}