diff --git a/deploy-iis/action.yml b/deploy-iis/action.yml index 72899c6..e834fa6 100644 --- a/deploy-iis/action.yml +++ b/deploy-iis/action.yml @@ -22,6 +22,10 @@ inputs: description: Elenco di file da escludere dal mirroring (separati da virgola, punto e virgola o newline). required: false default: appsettings.json + clean-destination: + description: Se 'true', elimina tutto il contenuto della cartella di destinazione (dopo aver fermato IIS) tranne appsettings.json, web.config e la cartella store. + required: false + default: 'false' runs: using: composite @@ -99,15 +103,27 @@ runs: try { & $appcmd stop site "/site.name:$site" - if ($LASTEXITCODE -ne 0) { throw "stop site fallito ($LASTEXITCODE)" } - $siteStopped = $true + if ($LASTEXITCODE -ne 0) { + Write-Warning "stop site fallito ($LASTEXITCODE) - si prosegue comunque" + } else { + $siteStopped = $true + } & $appcmd stop apppool "/apppool.name:$appPool" - if ($LASTEXITCODE -ne 0) { throw "stop apppool fallito ($LASTEXITCODE)" } - $poolStopped = $true + if ($LASTEXITCODE -ne 0) { + Write-Warning "stop apppool fallito ($LASTEXITCODE) - si prosegue comunque" + } else { + $poolStopped = $true + } New-Item -ItemType Directory -Force -Path $dst | Out-Null + if ('${{ inputs.clean-destination }}' -eq 'true') { + $keepItems = @('appsettings.json', 'web.config', 'store') + Get-ChildItem -Path $dst | Where-Object { $_.Name -notin $keepItems } | Remove-Item -Recurse -Force + Write-Host "Pulizia destinazione completata (keep: $($keepItems -join ', '))" + } + & robocopy @robocopyArgs $robocopyExitCode = $LASTEXITCODE if ($robocopyExitCode -ge 8) {