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
|
name: Build and Deploy CPRNIMS
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
runs-on: windows
|
runs-on: windows:host
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# ---- Build both .NET projects ----
|
- name: Clean previous publish output
|
||||||
- name: Publish WebApi
|
|
||||||
run: dotnet publish .\CPRNIMS.WebApi\CPRNIMS.WebApi.csproj -c Release -o D:\ci-output\webapi
|
|
||||||
shell: pwsh
|
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
|
- name: Publish WebApps
|
||||||
run: dotnet publish .\CPRNIMS.WebApps\CPRNIMS.WebApps.csproj -c Release -o D:\ci-output\webapps
|
|
||||||
shell: pwsh
|
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
|
- name: Stop app pools
|
||||||
|
shell: pwsh
|
||||||
run: |
|
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"
|
Import-Module WebAdministration
|
||||||
shell: pwsh
|
Stop-WebAppPool -Name "CPRNIMS-Api" -ErrorAction SilentlyContinue
|
||||||
|
Stop-WebAppPool -Name "CPRNIMS-Web" -ErrorAction SilentlyContinue
|
||||||
|
Start-Sleep -Seconds 3
|
||||||
|
|
||||||
- name: Copy WebApi
|
- name: Deploy WebApi files
|
||||||
run: scp -i D:\gitea-runner\deploy_key -r D:\ci-output\webapi\* lliadmin@212.47.72.54:C:/inetpub/cprnims-api/
|
|
||||||
shell: pwsh
|
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
|
- name: Deploy WebApps files
|
||||||
run: scp -i D:\gitea-runner\deploy_key -r D:\ci-output\webapps\* lliadmin@212.47.72.54:C:/inetpub/cprnims-web/
|
|
||||||
shell: pwsh
|
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
|
- name: Start app pools
|
||||||
|
shell: pwsh
|
||||||
run: |
|
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'"
|
Import-Module WebAdministration
|
||||||
shell: pwsh
|
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