Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge: stage to master #143

Merged
merged 8 commits into from
Feb 10, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/dev_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}/EmailSender.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 }}/EmailSender.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 }}/EmailSender.Configuration/appsettings.Staging.json
env:
Expand Down
3 changes: 3 additions & 0 deletions EmailSender.WebApi/EmailSender.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<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" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
28 changes: 26 additions & 2 deletions EmailSender.WebApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
using EmailSender.Backend.Core.Exceptions;
using EmailSender.WebApi.Configuration;
using EmailSender.WebApi.Middleware;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.ResponseCompression;
using Serilog;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace EmailSender.WebApi;
Expand Down Expand Up @@ -37,6 +40,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 @@ -49,13 +56,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("Email Sender 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));
}
});
}
}
Loading