Add: clean-destination input to optionally clear destination folder during IIS deployment
- Introduces a new input to allow cleanup of destination folder while retaining specific files and folders (`appsettings.json`, `web.config`, and `store`). - Updates error handling for IIS site and app pool stop commands to continue execution on failure.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user