Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a5724f5
Add GitHub Actions workflow for backend deployment
Khalilelk20 Jan 14, 2026
41ec392
infrastrcuture modules
Khalilelk20 Jan 14, 2026
3faefdc
step 1
Khalilelk20 Jan 14, 2026
2302399
deploy statical web app
Khalilelk20 Jan 14, 2026
0f57ef6
deploy statical web app step
Khalilelk20 Jan 14, 2026
c8d4495
Rename staticwebApp.bicep to staticWebApp.bicep
Khalilelk20 Jan 14, 2026
e4f6feb
duplicate app name on bicep main correction
Khalilelk20 Jan 14, 2026
73ffc99
Merge branch 'main' of https://github.com/Khalilelk20/parkndeploy
Khalilelk20 Jan 14, 2026
d804cc5
static web app bicep file review
Khalilelk20 Jan 14, 2026
13e7c56
deploy front end
Khalilelk20 Jan 14, 2026
817abbb
front end deploy
Khalilelk20 Jan 14, 2026
78aacd3
Update deploy-infra-and-apps.yml
Khalilelk20 Jan 14, 2026
97aa1c3
review gitflow yaml
Khalilelk20 Jan 14, 2026
a1adfa5
Merge branch 'main' of https://github.com/Khalilelk20/parkndeploy
Khalilelk20 Jan 14, 2026
3cdb024
review yaml gitflow file
Khalilelk20 Jan 14, 2026
b64f73d
review yaml workflow
Khalilelk20 Jan 14, 2026
663e67a
review yaml code
Khalilelk20 Jan 14, 2026
37cd7a2
correction workflow yaml
Khalilelk20 Jan 14, 2026
dc927ef
troubleshooting
Khalilelk20 Jan 14, 2026
0d7907c
troubleshooting frontend & backend
Khalilelk20 Jan 14, 2026
7ded8b3
ci: trigger deployment on semantic version tag
Khalilelk20 Jan 20, 2026
07a64b3
tag deployment
Khalilelk20 Jan 20, 2026
6c9a846
Add CI workflow for frontend and backend jobs
Khalilelk20 Jan 20, 2026
8d841e2
Refactor CI workflow for pull requests
Khalilelk20 Jan 20, 2026
1362fbb
Test CI pipeline
Khalilelk20 Jan 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
pull_request: # Ce workflow se déclenche uniquement sur les MR

jobs:
ci_merge_request:
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 --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
128 changes: 128 additions & 0 deletions .github/workflows/deploy-infra-and-apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Déclenche le workflow sur push ou déclenchement manuel
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

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 }}
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: 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
# --------------------------
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

# --------------------------
# 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: 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
with:
azure_static_web_apps_api_token: ${{ env.SWA_DEPLOYMENT_TOKEN }}
app_location: frontend/dist
action: upload
skip_app_build: true
skip_api_build: true
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ParkNDeploy</title>
<title>ParkNDeploy Testing CI</title>
</head>
<body>
<div id="root"></div>
Expand Down
59 changes: 59 additions & 0 deletions infrastructure/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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

// Static web app location
param swaLocation 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
}
}

// Create the Static Web App through the StaticWebApp module
module staticWebApp 'modules/staticWebApp.bicep' = {
name: 'staticWebApp'
params: {
location: swaLocation
project: project
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
23 changes: 23 additions & 0 deletions infrastructure/modules/appService.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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
output appServiceId string = app.id
20 changes: 20 additions & 0 deletions infrastructure/modules/appServicePlan.bicep
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions infrastructure/modules/staticWebApp.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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: 'Standard'
tier: 'Standard'
}

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
11 changes: 11 additions & 0 deletions infrastructure/modules/staticWebAppBackend.bicep
Original file line number Diff line number Diff line change
@@ -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
}
}