From f108e5ce145dc2de659e7a212a6c0da49c09d4d8 Mon Sep 17 00:00:00 2001 From: sige Date: Fri, 24 May 2024 17:08:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=91=E5=B8=83=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish.ps1 | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/publish.ps1 b/publish.ps1 index ccf2df0..c000b37 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -1,20 +1,32 @@ -# 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.10:/frontend/ -# unzip app.zip -ssh root:zwsd@192.168.8.10 "cd /frontend && unzip app.zip" -# remove old link -ssh root:zwsd@192.168.8.10 "cd /frontend && rm -f dist" -# create link -ssh root:zwsd@192.168.8.10 "cd /frontend && ln -s /frontend/$now /frontend/dist" -# remove app.zip -ssh root:zwsd@192.168.8.10 "cd /frontend && rm -f app.zip" -Remove-Item -Path ./app.zip -# remove folder -Remove-Item -Path ./$now -Recurse \ No newline at end of file +Param( + [String]$Exec="Deploy" +) + +if ( $Exec -eq "DevDisable" ) { + ssh root:zwsd@192.168.8.10 "rm /var/zapp_flag/chrome_in_test_mode"; + ssh root:zwsd@192.168.8.10 "reboot" +} elseif ( $Exec -eq "DevEnable" ) { + ssh root:zwsd@192.168.8.10 "touch /var/zapp_flag/chrome_in_test_mode"; + ssh root:zwsd@192.168.8.10 "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.10:/frontend/ + # unzip app.zip + ssh root:zwsd@192.168.8.10 "cd /frontend && unzip app.zip" + # remove old link + ssh root:zwsd@192.168.8.10 "cd /frontend && rm -f dist" + # create link + ssh root:zwsd@192.168.8.10 "cd /frontend && ln -s /frontend/$now /frontend/dist" + # remove app.zip + ssh root:zwsd@192.168.8.10 "cd /frontend && rm -f app.zip" + Remove-Item -Path ./app.zip + # remove folder + Remove-Item -Path ./$now -Recurse +} \ No newline at end of file