skip the images in path cprnims-web\wwwroot\Content\Images\
All checks were successful
Build and Deploy CPRNIMS / build-and-deploy (push) Successful in 3m3s

This commit is contained in:
rowell_m_soriano 2026-06-30 07:48:25 +08:00
parent 227ebe3906
commit d1686b15b7

View File

@ -66,7 +66,7 @@ jobs:
Write-Host "Wrote appsettings.Production.json to webapi output (values masked in this log automatically)"
exit 0
# ---- Generate production config for WebApps (uses Variables, not Secrets, since BaseUrl isn't sensitive) ----
# ---- Generate production config for WebApps (uses Variables, not Secrets, since BaseUrl is not sensitive) ----
- name: Write production appsettings - WebApps
shell: pwsh
env:
@ -97,15 +97,14 @@ jobs:
$stamp = Get-Date -Format "yyyyMMdd-HHmmss"
New-Item -ItemType Directory -Force -Path "C:\backups\$stamp" | Out-Null
# Mirror current live folders into the backup location (only if they exist / aren't empty)
if (Test-Path "C:\inetpub\cprnims-api") {
robocopy "C:\inetpub\cprnims-api" "C:\backups\$stamp\webapi" /MIR /R:2 /W:3 | Out-Null
}
# Exclude dynamic user images from backup - not part of deployable artifact
if (Test-Path "C:\inetpub\cprnims-web") {
robocopy "C:\inetpub\cprnims-web" "C:\backups\$stamp\webapps" /MIR /R:2 /W:3 | Out-Null
robocopy "C:\inetpub\cprnims-web" "C:\backups\$stamp\webapps" /MIR /R:2 /W:3 /XD "C:\inetpub\cprnims-web\wwwroot\Content\Images" | Out-Null
}
# Record this backup's timestamp so later steps know where it lives
$stamp | Out-File -FilePath "C:\backups\latest.txt" -Encoding ascii -NoNewline
# Keep only the last 5 backups to avoid filling the disk
@ -141,7 +140,8 @@ jobs:
id: deploy_web
shell: pwsh
run: |
robocopy "C:\ci-output\webapps" "C:\inetpub\cprnims-web" /MIR /R:3 /W:5
# /XD preserves dynamically uploaded images in Content\Images across deploys
robocopy "C:\ci-output\webapps" "C:\inetpub\cprnims-web" /MIR /R:3 /W:5 /XD "C:\inetpub\cprnims-web\wwwroot\Content\Images"
$rc = $LASTEXITCODE
Write-Host "ROBOCOPY EXIT CODE: $rc"
if ($rc -ge 8) {
@ -186,8 +186,9 @@ jobs:
if (Test-Path "$backupPath\webapi") {
robocopy "$backupPath\webapi" "C:\inetpub\cprnims-api" /MIR /R:3 /W:5 | Out-Null
}
# Exclude dynamic images from rollback restore - preserve images uploaded after the backup was taken
if (Test-Path "$backupPath\webapps") {
robocopy "$backupPath\webapps" "C:\inetpub\cprnims-web" /MIR /R:3 /W:5 | Out-Null
robocopy "$backupPath\webapps" "C:\inetpub\cprnims-web" /MIR /R:3 /W:5 /XD "C:\inetpub\cprnims-web\wwwroot\Content\Images" | Out-Null
}
Start-WebAppPool -Name "CPRNIMS-Api"