Skip to content

Commit

Permalink
CI/CD: Auto publish to azure
Browse files Browse the repository at this point in the history
  • Loading branch information
Shirasagi0012 committed Jul 25, 2024
1 parent 1636261 commit 6b53052
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 7 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/BerryJuice20240725020110.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and deploy .NET Core application to Web App BerryJuice20240725020110
on:
push:
branches:
- Shirasagi/Infrastructure/AddPostgresqlDependency
env:
AZURE_WEBAPP_NAME: BerryJuice20240725020110
AZURE_WEBAPP_PACKAGE_PATH: src\BerryJuice\published
CONFIGURATION: Release
DOTNET_CORE_VERSION: 8.0.x
WORKING_DIRECTORY: src\BerryJuice
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Restore
run: dotnet restore "${{ env.WORKING_DIRECTORY }}"
- name: Build
run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Test
run: dotnet test "${{ env.WORKING_DIRECTORY }}" --no-build
- name: Publish
run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
deploy:
runs-on: windows-latest
needs: build
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.BerryJuice20240725020110_E884 }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
2 changes: 2 additions & 0 deletions src/BerryJuice/BerryJuice.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.1" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.18" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "BerryJuice20240725020110ResourceGroup",
"metadata": {
"_parameterType": "resourceGroup",
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
}
},
"resourceGroupLocation": {
"type": "string",
"defaultValue": "eastus",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource group. Resource groups could have different location than resources."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[parameters('resourceGroupLocation')]",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"name": "[parameters('resourceGroupName')]",
"location": "[parameters('resourceGroupLocation')]",
"apiVersion": "2019-10-01"
},
{
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('berryjuice', subscription().subscriptionId)))]",
"resourceGroup": "[parameters('resourceGroupName')]",
"apiVersion": "2019-10-01",
"dependsOn": [
"[parameters('resourceGroupName')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"kind": "v12.0",
"location": "[parameters('resourceLocation')]",
"name": "sastcsharp",
"type": "Microsoft.Sql/servers",
"apiVersion": "2017-10-01-preview"
},
{
"sku": {
"name": "GP_S_Gen5",
"tier": "GeneralPurpose",
"family": "Gen5",
"capacity": 1
},
"kind": "v12.0,user,vcore,serverless,freelimit",
"location": "[parameters('resourceLocation')]",
"name": "sastcsharp/berryjuice",
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2017-10-01-preview",
"dependsOn": [
"sastcsharp"
]
}
]
}
}
}
],
"metadata": {
"_dependencyType": "mssql.azure"
}
}
20 changes: 15 additions & 5 deletions src/BerryJuice/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"applicationUrl": "http://localhost:5271",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"BERRYJUICE_USE_BLAZOR": "true"
"BERRYJUICE_USE_BLAZOR": "true",
"VaultUri": "https://berryjuicevault.vault.azure.net/",
"AZURE_USERNAME": "[email protected]"
}
},
"https": {
Expand All @@ -19,7 +21,9 @@
"applicationUrl": "https://localhost:5272;http://localhost:5271",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"BERRYJUICE_USE_BLAZOR": "true"
"BERRYJUICE_USE_BLAZOR": "true",
"VaultUri": "https://berryjuicevault.vault.azure.net/",
"AZURE_USERNAME": "[email protected]"
}
},
"http (WebAPI Only)": {
Expand All @@ -30,7 +34,9 @@
"applicationUrl": "http://localhost:5271",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"BERRYJUICE_USE_BLAZOR": "false"
"BERRYJUICE_USE_BLAZOR": "false",
"VaultUri": "https://berryjuicevault.vault.azure.net/",
"AZURE_USERNAME": "[email protected]"
}
},
"https (WebAPI Only)": {
Expand All @@ -41,7 +47,9 @@
"applicationUrl": "https://localhost:5272;http://localhost:5271",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"BERRYJUICE_USE_BLAZOR": "false"
"BERRYJUICE_USE_BLAZOR": "false",
"VaultUri": "https://berryjuicevault.vault.azure.net/",
"AZURE_USERNAME": "[email protected]"
}
},
"Container (Dockerfile)": {
Expand All @@ -50,7 +58,9 @@
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "5272",
"ASPNETCORE_HTTP_PORTS": "5271"
"ASPNETCORE_HTTP_PORTS": "5271",
"VaultUri": "https://berryjuicevault.vault.azure.net/",
"AZURE_USERNAME": "[email protected]"
},
"publishAllPorts": true,
"useSSL": true
Expand Down
16 changes: 14 additions & 2 deletions src/BerryJuice/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"dependencies": {
"mssql1": {
"type": "mssql",
"connectionId": "ConnectionStrings:CSharpGroupAzure"
},
"secrets2": {
"type": "secrets",
"connectionId": null
},
"postgresql1": {
"type": "postgresql",
"connectionId": "Berryjuice_PostgresConnection"
"ignored": "true",
"type": "postgresql"
},
"secrets1": {
"ignored": "true",
"type": "secrets.keyVault"
}
}
}

0 comments on commit 6b53052

Please sign in to comment.