Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
114 changes: 114 additions & 0 deletions .github/workflows/deploy-infra-and-apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
on:
push:
tags:
- 'v[0-9].[0-9].[0-9]'
workflow_dispatch:

permissions:
# Require write permission to Fetch an OIDC token (required for federated credential) and write it
# It will be automatically used on actions / cli that needs it
id-token: write

env:
AZURE_RG_NAME: rg-${{ vars.PROJECT_NAME }}-${{ vars.AZURE_RESOURCE_IDENTIFIER }}

jobs:
deploy_infrastructure:
runs-on: ubuntu-latest
environment: production

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

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 # Publish the app to the API project publish folder
working-directory: ./backend # Specify where to find the solution file in repository

- 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 }} # Access to the previous job output to get the appServiceName deployed with bicep
package: ./backend/ParkNDeploy.Api/publish # Path to the previously published app

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
41 changes: 41 additions & 0 deletions .github/workflows/merge-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
id-token: write

jobs:
build_react_app:
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build the app
run: npm install && npm run build
working-directory: ./frontend

- name: linting script
run: npm run lint
working-directory: ./frontend


build_backend:
runs-on: ubuntu-latest
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
25 changes: 25 additions & 0 deletions backend/Backup/ParkNDeploy.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35312.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParkNDeploy.Api", "ParkNDeploy.Api\ParkNDeploy.Api.csproj", "{20032B6D-23C2-4CE2-A4F7-0D1E8C477FBD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{20032B6D-23C2-4CE2-A4F7-0D1E8C477FBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20032B6D-23C2-4CE2-A4F7-0D1E8C477FBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20032B6D-23C2-4CE2-A4F7-0D1E8C477FBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20032B6D-23C2-4CE2-A4F7-0D1E8C477FBD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {456BA43D-278C-4316-ADEC-FD2A2C8C5A75}
EndGlobalSection
EndGlobal
Loading