Use Run From Package deployment method for F1 tier reliability #12
Workflow file for this run
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: Deploy PoFunQuiz to Azure | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| build-test-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 9.0 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Test | |
| run: dotnet test --no-build --configuration Release --verbosity normal --filter "Category!=E2E" | |
| continue-on-error: true # Don't fail build on test failures (some require OpenAI credentials) | |
| - name: Publish application | |
| run: dotnet publish PoFunQuiz.Server/PoFunQuiz.Server.csproj --configuration Release --output ./publish | |
| - name: Create deployment package | |
| run: | | |
| cd publish | |
| zip -r ../deploy.zip . | |
| cd .. | |
| - name: Azure Login (Federated Credentials) | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Upload package to Azure Storage | |
| run: | | |
| az storage blob upload \ | |
| --account-name pofunquiz \ | |
| --container-name deployments \ | |
| --name pofunquiz-${{ github.sha }}.zip \ | |
| --file deploy.zip \ | |
| --auth-mode login \ | |
| --overwrite | |
| BLOB_URL=$(az storage blob url \ | |
| --account-name pofunquiz \ | |
| --container-name deployments \ | |
| --name pofunquiz-${{ github.sha }}.zip \ | |
| --auth-mode login \ | |
| --output tsv) | |
| SAS_TOKEN=$(az storage blob generate-sas \ | |
| --account-name pofunquiz \ | |
| --container-name deployments \ | |
| --name pofunquiz-${{ github.sha }}.zip \ | |
| --permissions r \ | |
| --expiry $(date -u -d "+1 year" '+%Y-%m-%dT%H:%MZ') \ | |
| --auth-mode login \ | |
| --output tsv) | |
| PACKAGE_URL="${BLOB_URL}?${SAS_TOKEN}" | |
| az webapp config appsettings set \ | |
| --name PoFunQuiz \ | |
| --resource-group PoFunQuiz \ | |
| --settings WEBSITE_RUN_FROM_PACKAGE="$PACKAGE_URL" | |
| az webapp restart --name PoFunQuiz --resource-group PoFunQuiz | |
| - name: Wait for deployment | |
| run: sleep 30 | |
| - name: Health Check | |
| run: | | |
| APP_URL="https://pofunquiz.azurewebsites.net" | |
| echo "Testing health endpoint: $APP_URL/api/health" | |
| for i in {1..5}; do | |
| response=$(curl -s -o /dev/null -w "%{http_code}" $APP_URL/api/health) | |
| if [ $response -eq 200 ]; then | |
| echo "✅ Health check passed! Status code: $response" | |
| exit 0 | |
| else | |
| echo "⚠️ Attempt $i: Health check returned $response, retrying in 15s..." | |
| sleep 15 | |
| fi | |
| done | |
| echo "❌ Health check failed after 5 attempts" | |
| exit 1 | |
| - name: API Test via Swagger | |
| run: | | |
| APP_URL="https://pofunquiz.azurewebsites.net" | |
| echo "Testing Swagger endpoint: $APP_URL/swagger" | |
| response=$(curl -s -o /dev/null -w "%{http_code}" $APP_URL/swagger) | |
| if [ $response -eq 200 ] || [ $response -eq 301 ] || [ $response -eq 302 ]; then | |
| echo "✅ Swagger endpoint accessible! Status code: $response" | |
| else | |
| echo "⚠️ Swagger returned status code: $response (may need configuration)" | |
| fi | |
| - name: Functional Test | |
| run: | | |
| APP_URL="https://pofunquiz.azurewebsites.net" | |
| echo "Testing main app URL: $APP_URL" | |
| response=$(curl -s $APP_URL) | |
| if echo "$response" | grep -q "PoFunQuiz"; then | |
| echo "✅ Functional test passed! App title found in response" | |
| else | |
| echo "❌ Functional test failed! App title not found" | |
| exit 1 | |
| fi |