-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-push.ps1
45 lines (38 loc) · 1.42 KB
/
docker-push.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
try {
Write-Output "Starting Docker push process with elevated privileges..."
# Start elevated PowerShell process and execute the docker push command
$pushCommand = "docker-compose -f docker-compose.yml push"
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = "powershell.exe"
$startInfo.Arguments = "-Command `"& { $pushCommand }`""
$startInfo.Verb = "RunAs"
$startInfo.RedirectStandardOutput = $true
$startInfo.RedirectStandardError = $true
$startInfo.UseShellExecute = $false
$startInfo.CreateNoWindow = $true
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $startInfo
# Start the process
$process.Start() | Out-Null
# Capture output and errors
$standardOutput = $process.StandardOutput.ReadToEnd()
$standardError = $process.StandardError.ReadToEnd()
# Wait for the process to exit
$process.WaitForExit()
$exitCode = $process.ExitCode
# Output the results
Write-Output "Standard Output:"
Write-Output $standardOutput
Write-Output "Standard Error:"
Write-Output $standardError
if ($exitCode -eq 0) {
Write-Output "Docker push completed successfully."
} else {
Write-Output "Docker push encountered an error with exit code $exitCode."
exit 1
}
} catch {
Write-Output "Docker push failed."
Write-Output $_.Exception.Message
exit 1
}