From d1686b15b700bae6b51212a62d01abb4fc836337 Mon Sep 17 00:00:00 2001 From: rowell_m_soriano Date: Tue, 30 Jun 2026 07:48:25 +0800 Subject: [PATCH] skip the images in path cprnims-web\wwwroot\Content\Images\ --- .gitea/workflows/deploy.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 9b31a01..2be1697 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -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"