Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #154 from TomaszKandula/stage
Browse files Browse the repository at this point in the history
merge: stage to master
  • Loading branch information
TomaszKandula authored Feb 10, 2024
2 parents 8ea5256 + eb407ab commit 49ad77a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dev_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build & run tests (dev)
on:
pull_request:
branches: [ dev ]

jobs:

dev-branch-check:
Expand All @@ -23,7 +23,7 @@ jobs:
fetch-depth: 0

- name: Variable substitution appsettings file for Development (NET Core)
uses: TomaszKandula/variable-substitution@v1.0.1
uses: TomaszKandula/variable-substitution@v1.0.2
with:
files: ${{ github.workspace }}/InvoiceGenerator.Configuration/appsettings.Development.json
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/master_build_test_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
- name: Move results to outputs
id: versioning
run: |
echo "::set-output name=version::${{ steps.semantic.outputs.new_release_version }}"
echo "::set-output name=published::${{ steps.semantic.outputs.new_release_published }}"
echo "version=${{ steps.semantic.outputs.new_release_version }}" >> $GITHUB_OUTPUT
echo "published=${{ steps.semantic.outputs.new_release_published }}" >> $GITHUB_OUTPUT
backend-production:

Expand All @@ -53,7 +53,7 @@ jobs:
uses: actions/checkout@v4

- name: Variable substitution appsettings file for Production (NET Core)
uses: TomaszKandula/variable-substitution@v1.0.1
uses: TomaszKandula/variable-substitution@v1.0.2
with:
files: ${{ github.workspace }}/InvoiceGenerator.Configuration/appsettings.Production.json
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stage_build_test_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4

- name: Variable substitution appsettings file for Staging (NET Core)
uses: TomaszKandula/variable-substitution@v1.0.1
uses: TomaszKandula/variable-substitution@v1.0.2
with:
files: ${{ github.workspace }}/InvoiceGenerator.Configuration/appsettings.Staging.json
env:
Expand Down
2 changes: 2 additions & 0 deletions InvoiceGenerator.WebApi/InvoiceGenerator.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<PackageReference Include="Serilog.Sinks.AzureBlobStorage" Version="3.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.2.3" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.AzureStorage" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
30 changes: 28 additions & 2 deletions InvoiceGenerator.WebApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using InvoiceGenerator.Backend.Core.Exceptions;
using InvoiceGenerator.WebApi.Configuration;
using InvoiceGenerator.WebApi.Middleware;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Newtonsoft.Json;
using Serilog;
using Newtonsoft.Json.Converters;

Expand Down Expand Up @@ -42,6 +47,10 @@ public void ConfigureServices(IServiceCollection services)
services.RegisterDependencies(_configuration);
services.SetupSwaggerOptions(_environment);
services.SetupDockerInternalNetwork();
services
.AddHealthChecks()
.AddSqlServer(_configuration.GetValue<string>("DbConnect"), name: "SQLServer")
.AddAzureBlobStorage(_configuration.GetValue<string>("AZ_Storage_ConnectionString"), name: "AzureStorage");
}

public void Configure(IApplicationBuilder builder)
Expand All @@ -54,13 +63,30 @@ public void Configure(IApplicationBuilder builder)
builder.UseMiddleware<CacheControl>();
builder.UseResponseCompression();
builder.UseRouting();
builder.SetupSwaggerUi(_environment);
builder.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapGet("/", context
=> context.Response.WriteAsync("Invoice Generator API"));
});

builder.SetupSwaggerUi(_environment);
builder.UseHealthChecks("/hc", new HealthCheckOptions
{
ResponseWriter = async (context, report) =>
{
var result = new
{
status = report.Status.ToString(),
errors = report.Entries.Select(pair
=> new
{
key = pair.Key,
value = Enum.GetName(typeof(HealthStatus), pair.Value.Status)
})
};
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonConvert.SerializeObject(result));
}
});
}
}

0 comments on commit 49ad77a

Please sign in to comment.