Last active
January 21, 2019 08:13
-
-
Save josy1024/885c9922b306bca671460195e67abb96 to your computer and use it in GitHub Desktop.
deployinator for powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired deployinator for powershell | |
# http://blog.johngoulah.com/tag/deployinator/ | |
# author: josy1024@gmail.com | |
Function Get-Code ([String]$REPODIR, [String]$REPO) | |
{ | |
# controller deployinator | |
$host.ui.RawUI.WindowTitle = "git $REPO" | |
Write-Host git pull -ForegroundColor green | |
# change $REPODOMAIN to your hostname (eg ssh.dev.azure.com) let ssh add authorized keys ;-) | |
Start-Process -FilePath "ssh.exe" -WorkingDirectory "C:\Program Files\Git\usr\bin" -ArgumentList "-oStrictHostKeyChecking=no $REPODOMAIN uptime" | |
Start-Sleep -m 500 | |
Stop-Process -Name *ssh* -Force | |
if (-not ( "$REPODIR"| Test-Path)) { & git clone $REPO $REPODIR } | |
Set-Location $REPODIR | |
# debug origin | |
# & git remote show origin | |
& git fetch | |
& git reset --hard origin/master | |
Write-Host git pull reset done ... -ForegroundColor green | |
} | |
Function Push-Code ([String]$source, [String]$to) | |
{ | |
$debug=[int][Environment]::GetEnvironmentVariable("psdebuglevel") | |
$host.ui.RawUI.WindowTitle = "robocopy $source $debug" | |
if (( "$source" | Test-Path)) { | |
Write-Host "robocopy $source" -ForegroundColor green | |
if ($debug -ge 5) { | |
Write-Host robocopy /E /PURGE /W:0 /R:0 "$source" "$to" /NFL /XD .svn /XD .git /dcopy:T | |
} | |
& robocopy /E /PURGE /W:0 /R:0 "$source" "$to" /NFL /XD .svn /XD .git /dcopy:T | out-null | |
} | |
else | |
{ | |
Write-Host "$source not found" -ForegroundColor Red | |
} | |
} | |
$REPODIR="c:\repo" | |
Get-Code -REPODIR "$REPODIR" -REPO "git@ssh.dev.azure.com:v3/tenant/project/repo" | |
Push-Code -source "$REPODIR\code1" -to "\\serv1\publish\code1" | |
Push-Code -source "$REPODIR\code2" -to "\\serv2\publish\code2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment