You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
Param( [String]$Exec="Deploy" )
# 用于执行shell命令 function Exec-Shell-Cmd { Param($Cmd)
ssh root:zwsd@192.168.8.11 "cd /frontend && $Cmd" }
if ( $Exec -eq "DevDisable" ) { Exec-Shell-Cmd "rm /var/zapp_flag/chrome_in_test_mode"; Exec-Shell-Cmd "reboot" } elseif ( $Exec -eq "DevEnable" ) { Exec-Shell-Cmd "touch /var/zapp_flag/chrome_in_test_mode"; Exec-Shell-Cmd "reboot" } elseif ( $Exec -eq "Deploy" ) { # build project yarn build # rename dist to current time, like 20221215121300 $now = Get-Date -Format "yyyyMMddHHmmss" Rename-Item -Path ./dist -NewName $now # compress dist to app.zip Compress-Archive -Path ./$now -DestinationPath ./app.zip -Force # upload app.zip to server scp app.zip root@192.168.8.11:/frontend/ # unzip app.zip Exec-Shell-Cmd "unzip app.zip" # remove old link Exec-Shell-Cmd "rm -f /frontend/dist" # create link Exec-Shell-Cmd "ln -s /frontend/$now /frontend/dist" # remove app.zip Exec-Shell-Cmd "rm -f app.zip" Remove-Item -Path ./app.zip # remove folder Remove-Item -Path ./$now -Recurse }
|