Update Gitea CI/CD deployment workflow
Some checks are pending
Build and Deploy CPRNIMS / build-and-deploy (push) Waiting to run
Some checks are pending
Build and Deploy CPRNIMS / build-and-deploy (push) Waiting to run
This commit is contained in:
parent
8fdbe48640
commit
d6c2d668ee
@ -1,39 +1,66 @@
|
||||
name: Build and Deploy CPRNIMS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: windows
|
||||
runs-on: windows:host
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# ---- Build both .NET projects ----
|
||||
- name: Publish WebApi
|
||||
run: dotnet publish .\CPRNIMS.WebApi\CPRNIMS.WebApi.csproj -c Release -o D:\ci-output\webapi
|
||||
- name: Clean previous publish output
|
||||
shell: pwsh
|
||||
run: |
|
||||
Remove-Item -Recurse -Force "c:\ci-output\webapi" -ErrorAction SilentlyContinue
|
||||
Remove-Item -Recurse -Force "c:\ci-output\webapps" -ErrorAction SilentlyContinue
|
||||
|
||||
- name: Publish WebApi
|
||||
shell: pwsh
|
||||
run: dotnet publish .\CPRNIMS.WebApi\CPRNIMS.WebApi.csproj -c Release -o c:\ci-output\webapi
|
||||
|
||||
- name: Publish WebApps
|
||||
run: dotnet publish .\CPRNIMS.WebApps\CPRNIMS.WebApps.csproj -c Release -o D:\ci-output\webapps
|
||||
shell: pwsh
|
||||
run: dotnet publish .\CPRNIMS.WebApps\CPRNIMS.WebApps.csproj -c Release -o c:\ci-output\webapps
|
||||
|
||||
# ---- Deploy to IIS server over SSH ----
|
||||
- name: Stop app pools
|
||||
shell: pwsh
|
||||
run: |
|
||||
ssh -i D:\gitea-runner\deploy_key lliadmin@212.47.72.54 "Import-Module WebAdministration; Stop-WebAppPool -Name 'CPRNIMS-Api'; Stop-WebAppPool -Name 'CPRNIMS-Web'; Start-Sleep -Seconds 3"
|
||||
shell: pwsh
|
||||
Import-Module WebAdministration
|
||||
Stop-WebAppPool -Name "CPRNIMS-Api" -ErrorAction SilentlyContinue
|
||||
Stop-WebAppPool -Name "CPRNIMS-Web" -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
- name: Copy WebApi
|
||||
run: scp -i D:\gitea-runner\deploy_key -r D:\ci-output\webapi\* lliadmin@212.47.72.54:C:/inetpub/cprnims-api/
|
||||
- name: Deploy WebApi files
|
||||
shell: pwsh
|
||||
run: |
|
||||
robocopy "c:\ci-output\webapi" "C:\inetpub\cprnims-api" /MIR /R:3 /W:5
|
||||
if ($LASTEXITCODE -ge 8) { throw "robocopy failed for WebApi with exit code $LASTEXITCODE" }
|
||||
|
||||
- name: Copy WebApps
|
||||
run: scp -i D:\gitea-runner\deploy_key -r D:\ci-output\webapps\* lliadmin@212.47.72.54:C:/inetpub/cprnims-web/
|
||||
- name: Deploy WebApps files
|
||||
shell: pwsh
|
||||
run: |
|
||||
robocopy "c:\ci-output\webapps" "C:\inetpub\cprnims-web" /MIR /R:3 /W:5
|
||||
if ($LASTEXITCODE -ge 8) { throw "robocopy failed for WebApps with exit code $LASTEXITCODE" }
|
||||
|
||||
- name: Start app pools
|
||||
run: |
|
||||
ssh -i D:\gitea-runner\deploy_key lliadmin@212.47.72.54 "Import-Module WebAdministration; Start-WebAppPool -Name 'CPRNIMS-Api'; Start-WebAppPool -Name 'CPRNIMS-Web'"
|
||||
shell: pwsh
|
||||
run: |
|
||||
Import-Module WebAdministration
|
||||
Start-WebAppPool -Name "CPRNIMS-Api"
|
||||
Start-WebAppPool -Name "CPRNIMS-Web"
|
||||
|
||||
- name: Verify app pools are running
|
||||
shell: pwsh
|
||||
run: |
|
||||
Import-Module WebAdministration
|
||||
$api = Get-WebAppPoolState -Name "CPRNIMS-Api"
|
||||
$web = Get-WebAppPoolState -Name "CPRNIMS-Web"
|
||||
Write-Host "CPRNIMS-Api: $($api.Value)"
|
||||
Write-Host "CPRNIMS-Web: $($web.Value)"
|
||||
if ($api.Value -ne "Started" -or $web.Value -ne "Started") {
|
||||
throw "One or more app pools failed to start"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user