@@ -164,3 +164,56 @@ jobs:
164164 }
165165
166166 Write-Host "Deployment completed successfully!"
167+
168+ deploynice :
169+ needs : [build-test, e2e-tests]
170+ if : github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop'
171+ runs-on : windows-latest
172+
173+ steps :
174+ - name : Checkout repository
175+ uses : actions/checkout@v4
176+
177+ - name : Setup .NET 10
178+ uses : actions/setup-dotnet@v4
179+ with :
180+ dotnet-version : ' 10.0.x'
181+
182+ - name : Publish application
183+ run : dotnet publish src/MyBlog.Web/MyBlog.Web.csproj -c Release -o ./publish -r win-x86 --self-contained false
184+
185+ - name : Deploy via WebDeploy
186+ shell : pwsh
187+ env :
188+ DEPLOY_SOURCE : ${{ github.workspace }}\publish
189+ DEPLOY_SITE : ${{ secrets.NICE_WEBSITE_NAME }}
190+ DEPLOY_HOST : ${{ secrets.NICE_SERVER_COMPUTER_NAME }}
191+ DEPLOY_USER : ${{ secrets.NICE_SERVER_USERNAME }}
192+ DEPLOY_PASSWORD : ${{ secrets.NICE_SERVER_PASSWORD }}
193+ run : |
194+ $msdeployPath = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
195+
196+ if (-not (Test-Path $msdeployPath)) {
197+ Write-Host "Installing Web Deploy..."
198+ choco install webdeploy -y --no-progress
199+ }
200+
201+ Write-Host "Deploying to $env:DEPLOY_HOST..."
202+ Write-Host "Note: Using AppOffline rule to prevent file-in-use errors"
203+
204+ $sourceArg = "-source:contentPath=$env:DEPLOY_SOURCE"
205+ $destArg = "-dest:contentPath=$env:DEPLOY_SITE,computerName=https://$($env:DEPLOY_HOST):8172/MsDeploy.axd?site=$env:DEPLOY_SITE,userName=$env:DEPLOY_USER,password=$env:DEPLOY_PASSWORD,AuthType='Basic'"
206+
207+ & $msdeployPath -verb:sync $sourceArg $destArg `
208+ -allowUntrusted `
209+ -enableRule:DoNotDeleteRule `
210+ -enableRule:AppOffline `
211+ -retryAttempts:3 `
212+ -retryInterval:3000
213+
214+ if ($LASTEXITCODE -ne 0) {
215+ Write-Error "Deployment failed with exit code $LASTEXITCODE"
216+ exit 1
217+ }
218+
219+ Write-Host "Deployment completed successfully!"
0 commit comments