From 28d834c16cc5a467284c99008bbf0a1bf5e55d30 Mon Sep 17 00:00:00 2001 From: Malcom Foca <106889320+m4lcom@users.noreply.github.com> Date: Sun, 9 Nov 2025 18:54:39 -0300 Subject: [PATCH 1/9] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/main_smartwallet.yml | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/main_smartwallet.yml diff --git a/.github/workflows/main_smartwallet.yml b/.github/workflows/main_smartwallet.yml new file mode 100644 index 0000000..51f51f2 --- /dev/null +++ b/.github/workflows/main_smartwallet.yml @@ -0,0 +1,65 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy ASP.Net Core app to Azure Web App - Smartwallet + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + permissions: + contents: read #This is required for actions/checkout + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + + - name: Build with dotnet + run: dotnet build --configuration Release + + - name: dotnet publish + run: dotnet publish -c Release -o "${{env.DOTNET_ROOT}}/myapp" + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: .net-app + path: ${{env.DOTNET_ROOT}}/myapp + + deploy: + runs-on: windows-latest + needs: build + permissions: + id-token: write #This is required for requesting the JWT + contents: read #This is required for actions/checkout + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: .net-app + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F3A380A3B77D44AF83A0C2AD7D9E04D7 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BD645D025E5D422BA1884217379C67B3 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_009404B2EC734D30A88CFA7832D39842 }} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: 'Smartwallet' + slot-name: 'Production' + package: . + \ No newline at end of file From c4259a25d14094c7594498166e8c6a0396ae7653 Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 9 Nov 2025 19:09:39 -0300 Subject: [PATCH 2/9] Agregado de update database al workflow --- .github/workflows/main_smartwallet.yml | 33 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main_smartwallet.yml b/.github/workflows/main_smartwallet.yml index 51f51f2..5a2fb82 100644 --- a/.github/workflows/main_smartwallet.yml +++ b/.github/workflows/main_smartwallet.yml @@ -38,22 +38,35 @@ jobs: deploy: runs-on: windows-latest needs: build - permissions: - id-token: write #This is required for requesting the JWT - contents: read #This is required for actions/checkout + permissions: + id-token: write #This is required for requesting the JWT + contents: read #This is required for actions/checkout steps: + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + - name: Download artifact from build job uses: actions/download-artifact@v4 with: name: .net-app - - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F3A380A3B77D44AF83A0C2AD7D9E04D7 }} - tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BD645D025E5D422BA1884217379C67B3 }} - subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_009404B2EC734D30A88CFA7832D39842 }} + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F3A380A3B77D44AF83A0C2AD7D9E04D7 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BD645D025E5D422BA1884217379C67B3 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_009404B2EC734D30A88CFA7832D39842 }} + + - name: Install dotnet-ef tool + run: dotnet tool install --global dotnet-ef --version 8.* + + - name: Update database with EF Core migrations + run: dotnet ef database update --project src/SmartWallet.Infrastructure/SmartWallet.Infrastructure.csproj --startup-project src/SmartWallet.API/SmartWallet.API.csproj + env: + ASPNETCORE_ENVIRONMENT: Production - name: Deploy to Azure Web App id: deploy-to-webapp From 3eb22261a0764ec35287086facd29fe8037c8bb4 Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 9 Nov 2025 19:17:12 -0300 Subject: [PATCH 3/9] arreglando rutas de workflow --- .github/workflows/main_smartwallet.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main_smartwallet.yml b/.github/workflows/main_smartwallet.yml index 5a2fb82..62bffdd 100644 --- a/.github/workflows/main_smartwallet.yml +++ b/.github/workflows/main_smartwallet.yml @@ -64,15 +64,22 @@ jobs: run: dotnet tool install --global dotnet-ef --version 8.* - name: Update database with EF Core migrations - run: dotnet ef database update --project src/SmartWallet.Infrastructure/SmartWallet.Infrastructure.csproj --startup-project src/SmartWallet.API/SmartWallet.API.csproj + run: dotnet ef database update --project "${{ github.workspace }}/src/SmartWallet.Infrastructure/SmartWallet.Infrastructure.csproj" --startup-project "${{ github.workspace }}/src/SmartWallet.API/SmartWallet.API.csproj" env: ASPNETCORE_ENVIRONMENT: Production + - name: Debug workspace layout + run: | + echo "Workspace: $GITHUB_WORKSPACE" + pwd + ls -la + ls -la src || true + ls -la src/SmartWallet.Infrastructure || true + - name: Deploy to Azure Web App id: deploy-to-webapp uses: azure/webapps-deploy@v3 with: app-name: 'Smartwallet' slot-name: 'Production' - package: . - \ No newline at end of file + package: . \ No newline at end of file From d8f99c43f2a4be1e812893b124e851ff8db52bf2 Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 9 Nov 2025 19:24:04 -0300 Subject: [PATCH 4/9] arreglando workflow --- .github/workflows/main_smartwallet.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main_smartwallet.yml b/.github/workflows/main_smartwallet.yml index 62bffdd..4ebd0a6 100644 --- a/.github/workflows/main_smartwallet.yml +++ b/.github/workflows/main_smartwallet.yml @@ -43,6 +43,9 @@ jobs: contents: read #This is required for actions/checkout steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up .NET Core uses: actions/setup-dotnet@v4 with: @@ -61,21 +64,15 @@ jobs: subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_009404B2EC734D30A88CFA7832D39842 }} - name: Install dotnet-ef tool - run: dotnet tool install --global dotnet-ef --version 8.* + run: | + dotnet tool install --global dotnet-ef --version 8.* + echo "PATH=$Env:PATH;$Env:USERPROFILE\.dotnet\tools" >> $GITHUB_ENV - name: Update database with EF Core migrations run: dotnet ef database update --project "${{ github.workspace }}/src/SmartWallet.Infrastructure/SmartWallet.Infrastructure.csproj" --startup-project "${{ github.workspace }}/src/SmartWallet.API/SmartWallet.API.csproj" env: ASPNETCORE_ENVIRONMENT: Production - - name: Debug workspace layout - run: | - echo "Workspace: $GITHUB_WORKSPACE" - pwd - ls -la - ls -la src || true - ls -la src/SmartWallet.Infrastructure || true - - name: Deploy to Azure Web App id: deploy-to-webapp uses: azure/webapps-deploy@v3 From 9a772512c976af3fe1372e2a375e253be38e70a0 Mon Sep 17 00:00:00 2001 From: Ezequiel Natale <40499263+Eze-Nat@users.noreply.github.com> Date: Sun, 9 Nov 2025 19:52:34 -0300 Subject: [PATCH 5/9] testeando workflow --- .github/workflows/main_smartwallet.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main_smartwallet.yml b/.github/workflows/main_smartwallet.yml index 4ebd0a6..8f42d5c 100644 --- a/.github/workflows/main_smartwallet.yml +++ b/.github/workflows/main_smartwallet.yml @@ -39,8 +39,8 @@ jobs: runs-on: windows-latest needs: build permissions: - id-token: write #This is required for requesting the JWT - contents: read #This is required for actions/checkout + id-token: write # Required for requesting the JWT + contents: read # Required for actions/checkout steps: - name: Checkout repository @@ -50,28 +50,31 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.x' - + - name: Download artifact from build job uses: actions/download-artifact@v4 with: name: .net-app - + - name: Login to Azure uses: azure/login@v2 with: client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F3A380A3B77D44AF83A0C2AD7D9E04D7 }} tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BD645D025E5D422BA1884217379C67B3 }} subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_009404B2EC734D30A88CFA7832D39842 }} - + - name: Install dotnet-ef tool run: | dotnet tool install --global dotnet-ef --version 8.* echo "PATH=$Env:PATH;$Env:USERPROFILE\.dotnet\tools" >> $GITHUB_ENV - + - name: Update database with EF Core migrations - run: dotnet ef database update --project "${{ github.workspace }}/src/SmartWallet.Infrastructure/SmartWallet.Infrastructure.csproj" --startup-project "${{ github.workspace }}/src/SmartWallet.API/SmartWallet.API.csproj" + working-directory: src/SmartWallet.Infrastructure + run: dotnet ef database update --startup-project ../SmartWallet.API env: ASPNETCORE_ENVIRONMENT: Production + JWT_SECRET: ${{ secrets.JWT_SECRET }} + DB_PATH: ${{ secrets.DB_PATH }} - name: Deploy to Azure Web App id: deploy-to-webapp @@ -79,4 +82,4 @@ jobs: with: app-name: 'Smartwallet' slot-name: 'Production' - package: . \ No newline at end of file + package: . From 8fc8c1ab82021809f1a2e90831b7a15daad51274 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 10 Nov 2025 17:46:30 -0300 Subject: [PATCH 6/9] arreglando workflow --- .github/workflows/main_smartwallet.yml | 33 ++++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main_smartwallet.yml b/.github/workflows/main_smartwallet.yml index 8f42d5c..1fbf46d 100644 --- a/.github/workflows/main_smartwallet.yml +++ b/.github/workflows/main_smartwallet.yml @@ -1,6 +1,3 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions - name: Build and deploy ASP.Net Core app to Azure Web App - Smartwallet on: @@ -13,7 +10,7 @@ jobs: build: runs-on: windows-latest permissions: - contents: read #This is required for actions/checkout + contents: read steps: - uses: actions/checkout@v4 @@ -23,10 +20,16 @@ jobs: with: dotnet-version: '8.x' + - name: Restore dependencies + working-directory: src/SmartWallet.API + run: dotnet restore + - name: Build with dotnet - run: dotnet build --configuration Release + working-directory: src/SmartWallet.API + run: dotnet build --configuration Release --no-restore - - name: dotnet publish + - name: Publish app + working-directory: src/SmartWallet.API run: dotnet publish -c Release -o "${{env.DOTNET_ROOT}}/myapp" - name: Upload artifact for deployment job @@ -39,18 +42,10 @@ jobs: runs-on: windows-latest needs: build permissions: - id-token: write # Required for requesting the JWT - contents: read # Required for actions/checkout + id-token: write + contents: read steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up .NET Core - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '8.x' - - name: Download artifact from build job uses: actions/download-artifact@v4 with: @@ -68,7 +63,7 @@ jobs: dotnet tool install --global dotnet-ef --version 8.* echo "PATH=$Env:PATH;$Env:USERPROFILE\.dotnet\tools" >> $GITHUB_ENV - - name: Update database with EF Core migrations + - name: Apply EF Core migrations to Azure SQL working-directory: src/SmartWallet.Infrastructure run: dotnet ef database update --startup-project ../SmartWallet.API env: @@ -82,4 +77,6 @@ jobs: with: app-name: 'Smartwallet' slot-name: 'Production' - package: . + package: ${{ env.DOTNET_ROOT }}/myapp + env: + DB_PATH: ${{ secrets.DB_PATH }} From 22f58d25e1f1f21c22bccde42d1456f73d04282f Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 10 Nov 2025 17:52:32 -0300 Subject: [PATCH 7/9] arreglo workflow #5 --- .github/workflows/main_smartwallet.yml | 30 +++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main_smartwallet.yml b/.github/workflows/main_smartwallet.yml index 1fbf46d..0e01962 100644 --- a/.github/workflows/main_smartwallet.yml +++ b/.github/workflows/main_smartwallet.yml @@ -1,3 +1,6 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + name: Build and deploy ASP.Net Core app to Azure Web App - Smartwallet on: @@ -10,7 +13,7 @@ jobs: build: runs-on: windows-latest permissions: - contents: read + contents: read #This is required for actions/checkout steps: - uses: actions/checkout@v4 @@ -20,16 +23,10 @@ jobs: with: dotnet-version: '8.x' - - name: Restore dependencies - working-directory: src/SmartWallet.API - run: dotnet restore - - name: Build with dotnet - working-directory: src/SmartWallet.API - run: dotnet build --configuration Release --no-restore + run: dotnet build --configuration Release - - name: Publish app - working-directory: src/SmartWallet.API + - name: dotnet publish run: dotnet publish -c Release -o "${{env.DOTNET_ROOT}}/myapp" - name: Upload artifact for deployment job @@ -42,10 +39,18 @@ jobs: runs-on: windows-latest needs: build permissions: - id-token: write - contents: read + id-token: write # Required for requesting the JWT + contents: read # Required for actions/checkout steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + - name: Download artifact from build job uses: actions/download-artifact@v4 with: @@ -63,7 +68,7 @@ jobs: dotnet tool install --global dotnet-ef --version 8.* echo "PATH=$Env:PATH;$Env:USERPROFILE\.dotnet\tools" >> $GITHUB_ENV - - name: Apply EF Core migrations to Azure SQL + - name: Update database with EF Core migrations working-directory: src/SmartWallet.Infrastructure run: dotnet ef database update --startup-project ../SmartWallet.API env: @@ -79,4 +84,5 @@ jobs: slot-name: 'Production' package: ${{ env.DOTNET_ROOT }}/myapp env: + DOTNET_ROOT: ${{ env.DOTNET_ROOT }} DB_PATH: ${{ secrets.DB_PATH }} From 826383c9ea9bc4cd85f32f992c38e244d18fb6e1 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 10 Nov 2025 18:07:07 -0300 Subject: [PATCH 8/9] prueba workflow #8 --- src/SmartWallet.API/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SmartWallet.API/Program.cs b/src/SmartWallet.API/Program.cs index 8f9afd3..f2a8f04 100644 --- a/src/SmartWallet.API/Program.cs +++ b/src/SmartWallet.API/Program.cs @@ -7,7 +7,8 @@ var builder = WebApplication.CreateBuilder(args); // --- cargar .env --- -Env.TraversePath().Load(); +if (File.Exists(".env")) + Env.TraversePath().Load(); // --- validar variables --- var jwtSecret = Environment.GetEnvironmentVariable("JWT_SECRET"); @@ -17,7 +18,7 @@ throw new InvalidOperationException("Faltan variables en .env: JWT_SECRET o DB_PATH."); builder.Configuration["Jwt:Key"] = jwtSecret; -builder.Configuration["ConnectionStrings:DefaultConnection"] = $"Data Source={dbPath}"; +builder.Configuration["ConnectionStrings:DefaultConnection"] = dbPath; // --- servicios --- builder.Services.AddControllers(); From 1557e6bc8696afca6e068da0faf5f149f8c05569 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 10 Nov 2025 18:16:31 -0300 Subject: [PATCH 9/9] arreglando error de retry en el workflow --- .../Extensions/ServiceCollectionExtension.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/SmartWallet.Infrastructure/Extensions/ServiceCollectionExtension.cs b/src/SmartWallet.Infrastructure/Extensions/ServiceCollectionExtension.cs index 6a9d9ad..528b10a 100644 --- a/src/SmartWallet.Infrastructure/Extensions/ServiceCollectionExtension.cs +++ b/src/SmartWallet.Infrastructure/Extensions/ServiceCollectionExtension.cs @@ -46,7 +46,18 @@ public static IServiceCollection AddSmartWalletInfrastructure( // --- DbContext --- services.AddDbContext(options => - options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"))); + options.UseSqlServer( + configuration.GetConnectionString("DefaultConnection"), + sqlOptions => + { + sqlOptions.EnableRetryOnFailure( + maxRetryCount: 5, // Reintenta hasta 5 veces + maxRetryDelay: TimeSpan.FromSeconds(10), // Espera entre reintentos + errorNumbersToAdd: null // Aplica a errores transitorios comunes + ); + } + ) + ); return services; }