run dump #108
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build, Test, and Deploy | |
| on: | |
| push: | |
| branches: ['**'] | |
| pull_request: | |
| branches: ['**'] | |
| jobs: | |
| build-test: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 10 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore src/MyBlog.slnx | |
| - name: Build solution | |
| run: dotnet build src/MyBlog.slnx -c Release --no-restore | |
| - name: Run unit tests | |
| run: dotnet run --project src/MyBlog.Tests/MyBlog.Tests.csproj | |
| e2e-tests: | |
| runs-on: ubuntu-latest | |
| needs: build-test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 10 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore src/MyBlog.slnx | |
| - name: Build solution | |
| run: dotnet build src/MyBlog.slnx -c Release --no-restore | |
| - name: Install Playwright browsers | |
| run: | | |
| pwsh src/MyBlog.E2E/bin/Release/net10.0/playwright.ps1 install chromium --with-deps | |
| - name: Start MyBlog application | |
| run: | | |
| dotnet run --project src/MyBlog.Web/MyBlog.Web.csproj -c Release --no-build --no-launch-profile > app.log 2>&1 & | |
| echo $! > app.pid | |
| env: | |
| ASPNETCORE_URLS: http://localhost:5000 | |
| ASPNETCORE_ENVIRONMENT: Development | |
| Authentication__DefaultAdminPassword: ChangeMe123! | |
| - name: Wait for application to be ready | |
| run: | | |
| echo "Waiting for application to start..." | |
| for i in {1..60}; do | |
| if curl -sf http://localhost:5000/ > /dev/null 2>&1; then | |
| echo "Application is ready!" | |
| curl -v http://localhost:5000/ 2>&1 | head -20 | |
| break | |
| fi | |
| echo "Attempt $i/60: Application not ready yet..." | |
| sleep 2 | |
| if [ $i -eq 60 ]; then | |
| echo "Application failed to start within timeout" | |
| echo "Application logs:" | |
| cat app.log || echo "No logs available" | |
| exit 1 | |
| fi | |
| done | |
| - name: Run E2E tests | |
| run: dotnet run --project src/MyBlog.E2E/MyBlog.E2E.csproj -c Release --no-build | |
| env: | |
| MYBLOG_BASE_URL: http://localhost:5000 | |
| PLAYWRIGHT_HEADLESS: true | |
| - name: Stop application | |
| if: always() | |
| run: | | |
| if [ -f app.pid ]; then | |
| kill $(cat app.pid) || true | |
| fi | |
| - name: Show application logs on failure | |
| if: failure() | |
| run: | | |
| echo "=== Application Logs ===" | |
| cat app.log || echo "No logs available" | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: e2e-test-results | |
| path: | | |
| src/MyBlog.E2E/TestResults/ | |
| test-results/ | |
| app.log | |
| retention-days: 7 | |
| deploy: | |
| needs: [build-test, e2e-tests] | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 10 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Publish application | |
| run: dotnet publish src/MyBlog.Web/MyBlog.Web.csproj -c Release -o ./publish -r win-x86 --self-contained false | |
| - name: Deploy via WebDeploy | |
| shell: pwsh | |
| env: | |
| DEPLOY_SOURCE: ${{ github.workspace }}\publish | |
| DEPLOY_SITE: ${{ secrets.WEBSITE_NAME }} | |
| DEPLOY_HOST: ${{ secrets.SERVER_COMPUTER_NAME }} | |
| DEPLOY_USER: ${{ secrets.SERVER_USERNAME }} | |
| DEPLOY_PASSWORD: ${{ secrets.SERVER_PASSWORD }} | |
| run: | | |
| $msdeployPath = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" | |
| if (-not (Test-Path $msdeployPath)) { | |
| Write-Host "Installing Web Deploy..." | |
| choco install webdeploy -y --no-progress | |
| } | |
| Write-Host "Deploying to $env:DEPLOY_HOST..." | |
| Write-Host "Note: Using AppOffline rule to prevent file-in-use errors" | |
| $sourceArg = "-source:contentPath=$env:DEPLOY_SOURCE" | |
| $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'" | |
| & $msdeployPath -verb:sync $sourceArg $destArg ` | |
| -allowUntrusted ` | |
| -enableRule:DoNotDeleteRule ` | |
| -enableRule:AppOffline ` | |
| -retryAttempts:3 ` | |
| -retryInterval:3000 | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Error "Deployment failed with exit code $LASTEXITCODE" | |
| exit 1 | |
| } | |
| Write-Host "Deployment completed successfully!" | |
| deploynice: | |
| needs: [build-test, e2e-tests] | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 10 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Publish application | |
| run: dotnet publish src/MyBlog.Web/MyBlog.Web.csproj -c Release -o ./publish -r win-x86 --self-contained false | |
| - name: Deploy via WebDeploy | |
| shell: pwsh | |
| env: | |
| NICE_DEPLOY_SOURCE: ${{ github.workspace }}\publish | |
| NICE_DEPLOY_SITE: ${{ secrets.NICE_WEBSITE_NAME }} | |
| NICE_DEPLOY_HOST: ${{ secrets.NICE_SERVER_COMPUTER_NAME }} | |
| NICE_DEPLOY_USER: ${{ secrets.NICE_SERVER_USERNAME }} | |
| NICE_DEPLOY_PASSWORD: ${{ secrets.NICE_SERVER_PASSWORD }} | |
| run: | | |
| $msdeployPath = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" | |
| if (-not (Test-Path $msdeployPath)) { | |
| Write-Host "Installing Web Deploy..." | |
| choco install webdeploy -y --no-progress | |
| } | |
| Write-Host "Deploying to $env:NICE_DEPLOY_HOST..." | |
| Write-Host "Note: Using AppOffline rule to prevent file-in-use errors" | |
| $sourceArg = "-source:contentPath=$env:NICE_DEPLOY_SOURCE" | |
| $destArg = "-dest:contentPath=$env:NICE_DEPLOY_SITE,computerName=https://$($env:NICE_DEPLOY_HOST):8172/MsDeploy.axd?site=$env:NICE_DEPLOY_SITE,userName=$env:NICE_DEPLOY_USER,password=$env:NICE_DEPLOY_PASSWORD,AuthType='Basic'" | |
| & $msdeployPath -verb:sync $sourceArg $destArg ` | |
| -allowUntrusted ` | |
| -enableRule:DoNotDeleteRule ` | |
| -enableRule:AppOffline ` | |
| -retryAttempts:3 ` | |
| -retryInterval:3000 | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Error "Deployment failed with exit code $LASTEXITCODE" | |
| exit 1 | |
| } | |
| Write-Host "Deployment completed successfully!" |