From a5724f5e050be5eb714803273dff85cf767a86bc Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 14:58:59 +0100 Subject: [PATCH 01/23] Add GitHub Actions workflow for backend deployment --- .../workflows/deploy-infra-and-apps.yml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml diff --git a/infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml b/infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml new file mode 100644 index 00000000..1cc0144f --- /dev/null +++ b/infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml @@ -0,0 +1,35 @@ +on: [push, workflow_dispatch] + +env: + AZURE_RG_NAME: rg-${{ vars.PROJECT_NAME }}-${{ vars.AZURE_RESOURCE_IDENTIFIER }} + +jobs: + deploy_infrastructure: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + enable-AzPSSession: true + + - name: Create resource group if not exists + run: | + az group show --name ${{ env.AZURE_RG_NAME }} || + az group create --name ${{ env.AZURE_RG_NAME }} --location ${{ secrets.AZURE_REGION }} + + - name: Deploy bicep + id: bicep_deploy + uses: azure/arm-deploy@v2 + with: + subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} + region: ${{ secrets.AZURE_REGION }} + template: ./infrastructure/main.bicep + parameters: project=${{ vars.PROJECT_NAME }} location=${{ secrets.AZURE_REGION }} identifier=${{ vars.AZURE_RESOURCE_IDENTIFIER }} + resourceGroupName: ${{ env.AZURE_RG_NAME }} From 41ec392ac84a2f72bce901a15146208a520f7694 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 15:01:41 +0100 Subject: [PATCH 02/23] infrastrcuture modules --- infrastructure/main.bicep | 32 +++++++++++++++++++++ infrastructure/modules/appService.bicep | 22 ++++++++++++++ infrastructure/modules/appServicePlan.bicep | 20 +++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 infrastructure/main.bicep create mode 100644 infrastructure/modules/appService.bicep create mode 100644 infrastructure/modules/appServicePlan.bicep diff --git a/infrastructure/main.bicep b/infrastructure/main.bicep new file mode 100644 index 00000000..22bac17a --- /dev/null +++ b/infrastructure/main.bicep @@ -0,0 +1,32 @@ +targetScope = 'resourceGroup' // We'll deploy the resources in the provided resource group + +// Parameters to easily construct resource names +param location string +param project string + +// Here we'll add an identifier to create a unique name for the App Service Plan, for example your trigram, so that everyone could deploy his own parkndeploy instance +param identifier string + +// Create the AppServicePlan through the AppServicePlan module +module appServicePlan 'modules/appServicePlan.bicep' = { + name: 'appServicePlan' + params: { + location: location + project: project + identifier: identifier + } +} + +// Create the AppService through the AppService module +module appService 'modules/appService.bicep' = { + name: 'appService' + params: { + location: location + project: project + identifier: identifier + planId: appServicePlan.outputs.planId // Use the appServicePlan output to get its id back => an App Service needs to reference its App Service Plan + } +} + +// Export App Service Name +output appServiceName string = appService.outputs.appServiceName diff --git a/infrastructure/modules/appService.bicep b/infrastructure/modules/appService.bicep new file mode 100644 index 00000000..40b49099 --- /dev/null +++ b/infrastructure/modules/appService.bicep @@ -0,0 +1,22 @@ +param location string +param project string +param identifier string + +// App Service Plan identifier that will host our App Service +param planId string + +resource app 'Microsoft.Web/sites@2022-03-01' = { + name: '${project}-app-${identifier}' + location: location + + properties: { + serverFarmId: planId + reserved: true + + siteConfig: { + linuxFxVersion: 'DOTNETCORE|9.0' // Specify to setup the .NET Core 9.0 runtime (used by our backend API) on the Linux machine under the hood + } + } +} + +output appServiceName string = app.name // Export the App Service name for deployment diff --git a/infrastructure/modules/appServicePlan.bicep b/infrastructure/modules/appServicePlan.bicep new file mode 100644 index 00000000..c9b43403 --- /dev/null +++ b/infrastructure/modules/appServicePlan.bicep @@ -0,0 +1,20 @@ +param location string +param project string +param identifier string + +resource plan 'Microsoft.Web/serverfarms@2022-09-01' = { + name: '${project}-plan-${identifier}' + location: location + + sku: { + name: 'F1' // We use F1 pricing plan (free one) as we don't need specific features + } + + kind: 'app,linux' // Allow to deploy on an App Service using Linux OS + + properties: { + reserved: true // Specifity of App Service with Linux OS + } +} + +output planId string = plan.id // Export the App Service identifier From 3faefdc61dc1205dd8d4f6131bfbabb0fcdad7f7 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 15:10:17 +0100 Subject: [PATCH 03/23] step 1 --- .github/workflows/deploy-infra-and-apps.yml | 84 +++++++++++++++++++ infrastructure/main.bicep | 2 +- .../workflows/deploy-infra-and-apps.yml | 35 -------- infrastructure/modules/appService.bicep | 2 +- infrastructure/modules/appServicePlan.bicep | 2 +- 5 files changed, 87 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/deploy-infra-and-apps.yml delete mode 100644 infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml new file mode 100644 index 00000000..7f296647 --- /dev/null +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -0,0 +1,84 @@ +# Déclenche le workflow sur push ou déclenchement manuel +on: [push, workflow_dispatch] + +# Permissions pour OIDC + lecture du repo +permissions: + id-token: write + contents: read + +# Variables globales pour le workflow +env: + AZURE_RG_NAME: rg-${{ vars.PROJECT_NAME }}-${{ vars.AZURE_RESOURCE_IDENTIFIER }} + +jobs: + # -------------------------- + # Job 1 : Déployer l'infrastructure + # -------------------------- + deploy_infrastructure: + runs-on: ubuntu-latest + environment: production # Utilisation de ton Federated Credential + + # Exposer le nom de l'App Service pour le job backend + outputs: + appServiceName: ${{ steps.bicep_deploy.outputs.appServiceName }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + enable-AzPSSession: true + + - name: Create resource group if not exists + run: | + az group show --name ${{ env.AZURE_RG_NAME }} || + az group create --name ${{ env.AZURE_RG_NAME }} --location ${{ secrets.AZURE_REGION }} + + - name: Deploy bicep + id: bicep_deploy + uses: azure/arm-deploy@v2 + with: + subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + region: ${{ secrets.AZURE_REGION }} + template: ./infrastructure/main.bicep + parameters: project=${{ vars.PROJECT_NAME }} location=${{ secrets.AZURE_REGION }} identifier=${{ vars.AZURE_RESOURCE_IDENTIFIER }} + resourceGroupName: ${{ env.AZURE_RG_NAME }} + + # -------------------------- + # Job 2 : Déployer le backend API + # -------------------------- + deploy_backend: + runs-on: ubuntu-latest + needs: deploy_infrastructure + environment: production + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET SDK 9.0.x + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Publish the app + run: dotnet publish -c Release --property:PublishDir=publish + working-directory: ./backend + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Deploy backend to App Service + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ needs.deploy_infrastructure.outputs.appServiceName }} + package: ./backend/ParkNDeploy.Api/publish diff --git a/infrastructure/main.bicep b/infrastructure/main.bicep index 22bac17a..22252465 100644 --- a/infrastructure/main.bicep +++ b/infrastructure/main.bicep @@ -29,4 +29,4 @@ module appService 'modules/appService.bicep' = { } // Export App Service Name -output appServiceName string = appService.outputs.appServiceName +output appServiceName string = appService.outputs.appServiceName \ No newline at end of file diff --git a/infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml b/infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml deleted file mode 100644 index 1cc0144f..00000000 --- a/infrastructure/modules/.github/workflows/deploy-infra-and-apps.yml +++ /dev/null @@ -1,35 +0,0 @@ -on: [push, workflow_dispatch] - -env: - AZURE_RG_NAME: rg-${{ vars.PROJECT_NAME }}-${{ vars.AZURE_RESOURCE_IDENTIFIER }} - -jobs: - deploy_infrastructure: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - enable-AzPSSession: true - - - name: Create resource group if not exists - run: | - az group show --name ${{ env.AZURE_RG_NAME }} || - az group create --name ${{ env.AZURE_RG_NAME }} --location ${{ secrets.AZURE_REGION }} - - - name: Deploy bicep - id: bicep_deploy - uses: azure/arm-deploy@v2 - with: - subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} - region: ${{ secrets.AZURE_REGION }} - template: ./infrastructure/main.bicep - parameters: project=${{ vars.PROJECT_NAME }} location=${{ secrets.AZURE_REGION }} identifier=${{ vars.AZURE_RESOURCE_IDENTIFIER }} - resourceGroupName: ${{ env.AZURE_RG_NAME }} diff --git a/infrastructure/modules/appService.bicep b/infrastructure/modules/appService.bicep index 40b49099..740e0841 100644 --- a/infrastructure/modules/appService.bicep +++ b/infrastructure/modules/appService.bicep @@ -19,4 +19,4 @@ resource app 'Microsoft.Web/sites@2022-03-01' = { } } -output appServiceName string = app.name // Export the App Service name for deployment +output appServiceName string = app.name // Export the App Service name for deployment \ No newline at end of file diff --git a/infrastructure/modules/appServicePlan.bicep b/infrastructure/modules/appServicePlan.bicep index c9b43403..c871995f 100644 --- a/infrastructure/modules/appServicePlan.bicep +++ b/infrastructure/modules/appServicePlan.bicep @@ -17,4 +17,4 @@ resource plan 'Microsoft.Web/serverfarms@2022-09-01' = { } } -output planId string = plan.id // Export the App Service identifier +output planId string = plan.id // Export the App Service identifier \ No newline at end of file From 2302399b28873d057282832f315765fa5b7022c6 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 15:46:46 +0100 Subject: [PATCH 04/23] deploy statical web app --- .github/workflows/deploy-infra-and-apps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index 7f296647..0727a460 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -43,10 +43,10 @@ jobs: id: bicep_deploy uses: azure/arm-deploy@v2 with: - subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} region: ${{ secrets.AZURE_REGION }} template: ./infrastructure/main.bicep - parameters: project=${{ vars.PROJECT_NAME }} location=${{ secrets.AZURE_REGION }} identifier=${{ vars.AZURE_RESOURCE_IDENTIFIER }} + parameters: project=${{ vars.PROJECT_NAME }} location=${{ secrets.AZURE_REGION }} swaLocation=${{ secrets.AZURE_SWA_REGION }} identifier=${{ vars.AZURE_RESOURCE_IDENTIFIER }} resourceGroupName: ${{ env.AZURE_RG_NAME }} # -------------------------- From 0f57ef660aac07908e95aeef63ac8afa70c30cfa Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 15:47:17 +0100 Subject: [PATCH 05/23] deploy statical web app step --- infrastructure/main.bicep | 16 +++++++++++++++- infrastructure/modules/staticwebApp.bicep | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 infrastructure/modules/staticwebApp.bicep diff --git a/infrastructure/main.bicep b/infrastructure/main.bicep index 22252465..72320337 100644 --- a/infrastructure/main.bicep +++ b/infrastructure/main.bicep @@ -7,6 +7,9 @@ param project string // Here we'll add an identifier to create a unique name for the App Service Plan, for example your trigram, so that everyone could deploy his own parkndeploy instance param identifier string +// Static web app location +param swaLocation string + // Create the AppServicePlan through the AppServicePlan module module appServicePlan 'modules/appServicePlan.bicep' = { name: 'appServicePlan' @@ -28,5 +31,16 @@ module appService 'modules/appService.bicep' = { } } +// Create the Static Web App through the StaticWebApp module +module staticWebApp 'modules/staticWebApp.bicep' = { + name: 'staticWebApp' + params: { + location: swaLocation + project: project + identifier: identifier + } +} // Export App Service Name -output appServiceName string = appService.outputs.appServiceName \ No newline at end of file +output appServiceName string = appService.outputs.appServiceName +output appServiceName string = appService.outputs.appServiceName // Export AppServiceName in order to deploy the API later on +output staticWebAppName string = staticWebApp.outputs.swaName // Export StaticWebAppName in order to deploy the Frontend late \ No newline at end of file diff --git a/infrastructure/modules/staticwebApp.bicep b/infrastructure/modules/staticwebApp.bicep new file mode 100644 index 00000000..6e3be365 --- /dev/null +++ b/infrastructure/modules/staticwebApp.bicep @@ -0,0 +1,16 @@ +param location string +param project string +param identifier string + +resource swa 'Microsoft.Web/staticSites@2024-04-01 ' = { + name: '${project}-swa-${identifier}' + location: location + + sku: { + name: 'Free' + } + + properties: {} // Even empty, it's mandatory ... +} + +output swaName string = swa.name // Expose Static Web App name as we did for App Service for deployment purpose \ No newline at end of file From c8d44953d714d520ed92ce6c52f836c4329efddc Mon Sep 17 00:00:00 2001 From: Khalilelk20 <139553035+Khalilelk20@users.noreply.github.com> Date: Wed, 14 Jan 2026 15:51:21 +0100 Subject: [PATCH 06/23] Rename staticwebApp.bicep to staticWebApp.bicep --- .../modules/{staticwebApp.bicep => staticWebApp.bicep} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename infrastructure/modules/{staticwebApp.bicep => staticWebApp.bicep} (87%) diff --git a/infrastructure/modules/staticwebApp.bicep b/infrastructure/modules/staticWebApp.bicep similarity index 87% rename from infrastructure/modules/staticwebApp.bicep rename to infrastructure/modules/staticWebApp.bicep index 6e3be365..58806c9e 100644 --- a/infrastructure/modules/staticwebApp.bicep +++ b/infrastructure/modules/staticWebApp.bicep @@ -13,4 +13,4 @@ resource swa 'Microsoft.Web/staticSites@2024-04-01 ' = { properties: {} // Even empty, it's mandatory ... } -output swaName string = swa.name // Expose Static Web App name as we did for App Service for deployment purpose \ No newline at end of file +output swaName string = swa.name // Expose Static Web App name as we did for App Service for deployment purpose From e4f6febd7b4005a76906ea4f682517bb9e8f1d69 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 15:55:48 +0100 Subject: [PATCH 07/23] duplicate app name on bicep main correction --- infrastructure/main.bicep | 1 - 1 file changed, 1 deletion(-) diff --git a/infrastructure/main.bicep b/infrastructure/main.bicep index 72320337..4b1e64e9 100644 --- a/infrastructure/main.bicep +++ b/infrastructure/main.bicep @@ -42,5 +42,4 @@ module staticWebApp 'modules/staticWebApp.bicep' = { } // Export App Service Name output appServiceName string = appService.outputs.appServiceName -output appServiceName string = appService.outputs.appServiceName // Export AppServiceName in order to deploy the API later on output staticWebAppName string = staticWebApp.outputs.swaName // Export StaticWebAppName in order to deploy the Frontend late \ No newline at end of file From d804cc56fe7c540ff1a357fe09a883cbd46877f1 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:05:41 +0100 Subject: [PATCH 08/23] static web app bicep file review --- infrastructure/modules/staticWebApp.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/modules/staticWebApp.bicep b/infrastructure/modules/staticWebApp.bicep index 58806c9e..cd780056 100644 --- a/infrastructure/modules/staticWebApp.bicep +++ b/infrastructure/modules/staticWebApp.bicep @@ -2,7 +2,7 @@ param location string param project string param identifier string -resource swa 'Microsoft.Web/staticSites@2024-04-01 ' = { +resource swa 'Microsoft.Web/staticSites@2024-04-01' = { name: '${project}-swa-${identifier}' location: location From 13e7c569ef779bf72b3c8b04448d9e6698d0f179 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:13:11 +0100 Subject: [PATCH 09/23] deploy front end --- .github/workflows/deploy-infra-and-apps.yml | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index 0727a460..0beec4e2 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -21,6 +21,7 @@ jobs: # Exposer le nom de l'App Service pour le job backend outputs: appServiceName: ${{ steps.bicep_deploy.outputs.appServiceName }} + staticWebAppName: ${{ steps.bicep_deploy.outputs.staticWebAppName }} steps: - name: Checkout repository @@ -82,3 +83,34 @@ jobs: with: app-name: ${{ needs.deploy_infrastructure.outputs.appServiceName }} package: ./backend/ParkNDeploy.Api/publish + + + + #deploy front end + deploy_frontend: + runs-on: ubuntu-latest + needs: deploy_infrastructure + environment: production + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build the app + run: npm install && npm run build + working-directory: ./frontend + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Deploy frontend to Static Web App + uses: azure/static-web-apps-deploy@v1 + with: + app_location: frontend/dist + action: upload + skip_app_build: true + skip_api_build: true \ No newline at end of file From 817abbb36a3d2e1eb85387aa06f5619567971043 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:20:46 +0100 Subject: [PATCH 10/23] front end deploy --- .github/workflows/deploy-infra-and-apps.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index 0beec4e2..ea2e624e 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -34,6 +34,11 @@ jobs: tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} enable-AzPSSession: true + + - name: Get Static Web App deployment token + run: | + SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) + echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV - name: Create resource group if not exists run: | From 78aacd398e2d176d99f97044f6e1eb0805280dac Mon Sep 17 00:00:00 2001 From: Khalilelk20 <139553035+Khalilelk20@users.noreply.github.com> Date: Wed, 14 Jan 2026 16:24:31 +0100 Subject: [PATCH 11/23] Update deploy-infra-and-apps.yml --- .github/workflows/deploy-infra-and-apps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index ea2e624e..45b0dc38 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -35,7 +35,7 @@ jobs: subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} enable-AzPSSession: true - - name: Get Static Web App deployment token + - name: Get Static Web App deployment token run: | SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV @@ -118,4 +118,4 @@ jobs: app_location: frontend/dist action: upload skip_app_build: true - skip_api_build: true \ No newline at end of file + skip_api_build: true From 97aa1c3daab9d8e69fa05ca4fd04dba6967e9d46 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:26:36 +0100 Subject: [PATCH 12/23] review gitflow yaml --- .github/workflows/deploy-infra-and-apps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index ea2e624e..5f102d8c 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -40,6 +40,7 @@ jobs: SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV + - name: Create resource group if not exists run: | az group show --name ${{ env.AZURE_RG_NAME }} || From 3cdb024b6d5d389d348e6132c2999926ea0a6533 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:29:34 +0100 Subject: [PATCH 13/23] review yaml gitflow file --- .github/workflows/deploy-infra-and-apps.yml | 155 ++++++++++---------- 1 file changed, 77 insertions(+), 78 deletions(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index 4af81491..49315c6f 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -24,37 +24,36 @@ jobs: staticWebAppName: ${{ steps.bicep_deploy.outputs.staticWebAppName }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - enable-AzPSSession: true - - - name: Get Static Web App deployment token - run: | - SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) - echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV - - - - name: Create resource group if not exists - run: | - az group show --name ${{ env.AZURE_RG_NAME }} || - az group create --name ${{ env.AZURE_RG_NAME }} --location ${{ secrets.AZURE_REGION }} - - - name: Deploy bicep - id: bicep_deploy - uses: azure/arm-deploy@v2 - with: - subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} - region: ${{ secrets.AZURE_REGION }} - template: ./infrastructure/main.bicep - parameters: project=${{ vars.PROJECT_NAME }} location=${{ secrets.AZURE_REGION }} swaLocation=${{ secrets.AZURE_SWA_REGION }} identifier=${{ vars.AZURE_RESOURCE_IDENTIFIER }} - resourceGroupName: ${{ env.AZURE_RG_NAME }} + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + enable-AzPSSession: true + + - name: Get Static Web App deployment token + run: | + SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) + echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV + + - name: Create resource group if not exists + run: | + az group show --name ${{ env.AZURE_RG_NAME }} || + az group create --name ${{ env.AZURE_RG_NAME }} --location ${{ secrets.AZURE_REGION }} + + - name: Deploy bicep + id: bicep_deploy + uses: azure/arm-deploy@v2 + with: + subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} + region: ${{ secrets.AZURE_REGION }} + template: ./infrastructure/main.bicep + parameters: project=${{ vars.PROJECT_NAME }} location=${{ secrets.AZURE_REGION }} swaLocation=${{ secrets.AZURE_SWA_REGION }} identifier=${{ vars.AZURE_RESOURCE_IDENTIFIER }} + resourceGroupName: ${{ env.AZURE_RG_NAME }} # -------------------------- # Job 2 : Déployer le backend API @@ -65,58 +64,58 @@ jobs: environment: production steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup .NET SDK 9.0.x - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9.0.x' - - - name: Publish the app - run: dotnet publish -c Release --property:PublishDir=publish - working-directory: ./backend - - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Checkout repository + uses: actions/checkout@v4 - - name: Deploy backend to App Service - uses: azure/webapps-deploy@v2 - with: - app-name: ${{ needs.deploy_infrastructure.outputs.appServiceName }} - package: ./backend/ParkNDeploy.Api/publish - - + - name: Setup .NET SDK 9.0.x + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Publish the app + run: dotnet publish -c Release --property:PublishDir=publish + working-directory: ./backend + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Deploy backend to App Service + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ needs.deploy_infrastructure.outputs.appServiceName }} + package: ./backend/ParkNDeploy.Api/publish - #deploy front end + # -------------------------- + # Job 3 : Déployer le frontend + # -------------------------- deploy_frontend: runs-on: ubuntu-latest needs: deploy_infrastructure environment: production steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Build the app - run: npm install && npm run build - working-directory: ./frontend - - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - - name: Deploy frontend to Static Web App - uses: azure/static-web-apps-deploy@v1 - with: - app_location: frontend/dist - action: upload - skip_app_build: true - skip_api_build: true + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build the app + run: npm install && npm run build + working-directory: ./frontend + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Deploy frontend to Static Web App + uses: azure/static-web-apps-deploy@v1 + with: + app_location: frontend/dist + action: upload + skip_app_build: true + skip_api_build: true From b64f73d9e573c427efb1f3a8d6330e3d15719779 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:37:49 +0100 Subject: [PATCH 14/23] review yaml workflow --- .github/workflows/deploy-infra-and-apps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index 49315c6f..0727516f 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -21,7 +21,7 @@ jobs: # Exposer le nom de l'App Service pour le job backend outputs: appServiceName: ${{ steps.bicep_deploy.outputs.appServiceName }} - staticWebAppName: ${{ steps.bicep_deploy.outputs.staticWebAppName }} + staticWebAppName: ${{ steps.bicep_deploy.outputs.swaName }} steps: - name: Checkout repository @@ -37,7 +37,7 @@ jobs: - name: Get Static Web App deployment token run: | - SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) + SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.swaName }} -o tsv --query properties.apiKey) echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV - name: Create resource group if not exists From 663e67a1132818708aa3842260cf1af2997a0267 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:50:33 +0100 Subject: [PATCH 15/23] review yaml code --- .github/workflows/deploy-infra-and-apps.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index 0727516f..a8a030c6 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -21,7 +21,7 @@ jobs: # Exposer le nom de l'App Service pour le job backend outputs: appServiceName: ${{ steps.bicep_deploy.outputs.appServiceName }} - staticWebAppName: ${{ steps.bicep_deploy.outputs.swaName }} + staticWebAppName: ${{ steps.bicep_deploy.outputs.staticWebAppName }} steps: - name: Checkout repository @@ -37,7 +37,7 @@ jobs: - name: Get Static Web App deployment token run: | - SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.swaName }} -o tsv --query properties.apiKey) + SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV - name: Create resource group if not exists @@ -115,6 +115,7 @@ jobs: - name: Deploy frontend to Static Web App uses: azure/static-web-apps-deploy@v1 with: + azure_static_web_apps_api_token: ${{ env.SWA_DEPLOYMENT_TOKEN }} app_location: frontend/dist action: upload skip_app_build: true From 37cd7a23fd5026966c6a5679599df7ad979c5b88 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 16:58:55 +0100 Subject: [PATCH 16/23] correction workflow yaml --- .github/workflows/deploy-infra-and-apps.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index a8a030c6..f3728091 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -35,11 +35,6 @@ jobs: subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} enable-AzPSSession: true - - name: Get Static Web App deployment token - run: | - SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) - echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV - - name: Create resource group if not exists run: | az group show --name ${{ env.AZURE_RG_NAME }} || @@ -111,6 +106,11 @@ jobs: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Get Static Web App deployment token + run: | + SWA_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list -n ${{ needs.deploy_infrastructure.outputs.staticWebAppName }} -o tsv --query properties.apiKey) + echo SWA_DEPLOYMENT_TOKEN=$SWA_DEPLOYMENT_TOKEN >> $GITHUB_ENV - name: Deploy frontend to Static Web App uses: azure/static-web-apps-deploy@v1 From dc927efddbf7a3aff71cc6e651810dff476c1dd1 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 17:07:24 +0100 Subject: [PATCH 17/23] troubleshooting --- infrastructure/modules/appService.bicep | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/infrastructure/modules/appService.bicep b/infrastructure/modules/appService.bicep index 740e0841..dbe7a75b 100644 --- a/infrastructure/modules/appService.bicep +++ b/infrastructure/modules/appService.bicep @@ -19,4 +19,5 @@ resource app 'Microsoft.Web/sites@2022-03-01' = { } } -output appServiceName string = app.name // Export the App Service name for deployment \ No newline at end of file +output appServiceName string = app.name // Export the App Service name for deployment +output appServiceId string = app.id From 0d7907cda61c9e26cc1276c414b53d01898727a9 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Wed, 14 Jan 2026 17:07:45 +0100 Subject: [PATCH 18/23] troubleshooting frontend & backend --- infrastructure/main.bicep | 16 +++++++++++++++- infrastructure/modules/staticWebApp.bicep | 7 ++++--- infrastructure/modules/staticWebAppBackend.bicep | 11 +++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 infrastructure/modules/staticWebAppBackend.bicep diff --git a/infrastructure/main.bicep b/infrastructure/main.bicep index 4b1e64e9..1b58b1b6 100644 --- a/infrastructure/main.bicep +++ b/infrastructure/main.bicep @@ -40,6 +40,20 @@ module staticWebApp 'modules/staticWebApp.bicep' = { identifier: identifier } } + +// Previous resources +// ... +module staticWebAppBackend 'modules/staticWebAppBackend.bicep' = { + name: 'staticWebAppBackend' + params: { + backendBindedResourceId: appService.outputs.appServiceId + swaName: staticWebApp.outputs.swaName + location: location + } +} + +// Outputs +// ... // Export App Service Name output appServiceName string = appService.outputs.appServiceName -output staticWebAppName string = staticWebApp.outputs.swaName // Export StaticWebAppName in order to deploy the Frontend late \ No newline at end of file +output staticWebAppName string = staticWebApp.outputs.swaName // Export StaticWebAppName in order to deploy the Frontend late diff --git a/infrastructure/modules/staticWebApp.bicep b/infrastructure/modules/staticWebApp.bicep index cd780056..949c3043 100644 --- a/infrastructure/modules/staticWebApp.bicep +++ b/infrastructure/modules/staticWebApp.bicep @@ -6,9 +6,10 @@ resource swa 'Microsoft.Web/staticSites@2024-04-01' = { name: '${project}-swa-${identifier}' location: location - sku: { - name: 'Free' - } + sku: { + name: 'Standard' + tier: 'Standard' +} properties: {} // Even empty, it's mandatory ... } diff --git a/infrastructure/modules/staticWebAppBackend.bicep b/infrastructure/modules/staticWebAppBackend.bicep new file mode 100644 index 00000000..4e902770 --- /dev/null +++ b/infrastructure/modules/staticWebAppBackend.bicep @@ -0,0 +1,11 @@ +param backendBindedResourceId string +param swaName string +param location string + +resource staticWebAppBackend 'Microsoft.Web/staticSites/linkedBackends@2022-03-01' = { + name: '${swaName}/backend' + properties: { + backendResourceId: backendBindedResourceId + region: location + } +} From 7ded8b347f68e7ab5f24afbc8fd5e9a51b5798aa Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Tue, 20 Jan 2026 09:25:09 +0100 Subject: [PATCH 19/23] ci: trigger deployment on semantic version tag --- .github/workflows/deploy-infra-and-apps.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index f3728091..1fc54729 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -1,5 +1,10 @@ # Déclenche le workflow sur push ou déclenchement manuel -on: [push, workflow_dispatch] +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: + # Permissions pour OIDC + lecture du repo permissions: From 07a64b3c09af4939e2fb900d0bfcd2ea0348ec49 Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Tue, 20 Jan 2026 09:58:05 +0100 Subject: [PATCH 20/23] tag deployment --- .github/workflows/deploy-infra-and-apps.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-infra-and-apps.yml b/.github/workflows/deploy-infra-and-apps.yml index 1fc54729..aa936c02 100644 --- a/.github/workflows/deploy-infra-and-apps.yml +++ b/.github/workflows/deploy-infra-and-apps.yml @@ -2,7 +2,8 @@ on: push: tags: - - 'v*.*.*' + - 'v[0-9]+.[0-9]+.[0-9]+' + workflow_dispatch: From 6c9a846491288131bb2fd794bb001189ceae56f4 Mon Sep 17 00:00:00 2001 From: Khalilelk20 <139553035+Khalilelk20@users.noreply.github.com> Date: Tue, 20 Jan 2026 10:17:22 +0100 Subject: [PATCH 21/23] Add CI workflow for frontend and backend jobs --- .github/workflows/ci-pr.yml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/ci-pr.yml diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 00000000..4a7ddfeb --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -0,0 +1,54 @@ +# Déclenche le workflow uniquement sur Pull Requests vers la branche main +on: + pull_request: + branches: + - main + +# Permissions pour le workflow +permissions: + contents: read + +jobs: + # -------------------------- + # Job 1 : Frontend + # -------------------------- + frontend: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # ou la version utilisée dans ton projet + + - name: Install dependencies + run: npm install + working-directory: ./frontend + + - name: Build frontend + run: npm run build + working-directory: ./frontend + + - name: Run linter + run: npm run lint + working-directory: ./frontend + + # -------------------------- + # Job 2 : Backend + # -------------------------- + backend: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Build backend + run: dotnet build -c Release + working-directory: ./backend From 8d841e298977f3620c347b78ccf9028d2ae68ae9 Mon Sep 17 00:00:00 2001 From: Khalilelk20 <139553035+Khalilelk20@users.noreply.github.com> Date: Tue, 20 Jan 2026 10:23:43 +0100 Subject: [PATCH 22/23] Refactor CI workflow for pull requests --- .github/workflows/ci-pr.yml | 56 ++++++++++++------------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 4a7ddfeb..d28ee18e 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -1,54 +1,34 @@ -# Déclenche le workflow uniquement sur Pull Requests vers la branche main on: - pull_request: - branches: - - main - -# Permissions pour le workflow -permissions: - contents: read + pull_request: # Ce workflow se déclenche uniquement sur les MR jobs: - # -------------------------- - # Job 1 : Frontend - # -------------------------- - frontend: + ci_merge_request: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' # ou la version utilisée dans ton projet - - name: Install dependencies - run: npm install - working-directory: ./frontend - - - name: Build frontend - run: npm run build - working-directory: ./frontend - - - name: Run linter - run: npm run lint - working-directory: ./frontend - - # -------------------------- - # Job 2 : Backend - # -------------------------- - backend: - runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 + # Backend - name: Setup .NET SDK uses: actions/setup-dotnet@v4 with: dotnet-version: '9.0.x' - name: Build backend - run: dotnet build -c Release + run: dotnet build --configuration Release working-directory: ./backend + + # Frontend + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: '21.7.1' + + - name: Build frontend + run: npm install && npm run build + working-directory: ./frontend + + - name: Lint frontend + run: npm run lint + working-directory: ./frontend From 1362fbb1928bb116a39306d33ad4e02798d1ea1c Mon Sep 17 00:00:00 2001 From: Khalilelk20 Date: Tue, 20 Jan 2026 10:30:49 +0100 Subject: [PATCH 23/23] Test CI pipeline --- frontend/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/index.html b/frontend/index.html index 0a5274f1..19171662 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - ParkNDeploy + ParkNDeploy Testing CI