feat(telegram): configure deploy status and error level logging notification via Telegram API
Deploy to Production / Build Release Package (push) Failing after 19s
WBS-9.3 - NULL Policy CI Gate / NULL Policy Validation (push) Failing after 5s
Deploy to Production / Deploy to Production Server (push) Has been skipped
Deploy to Production / Post-Deployment Checks (push) Has been skipped
Snapshot Admin Deployment / build-and-deploy (push) Failing after 37s
Quant Engine CI/CD Pipeline / validate-core (push) Failing after 2m18s
Quant Engine CI/CD Pipeline / validate-ui-and-storage (push) Has been skipped
Deploy to Production / Build Release Package (push) Failing after 19s
WBS-9.3 - NULL Policy CI Gate / NULL Policy Validation (push) Failing after 5s
Deploy to Production / Deploy to Production Server (push) Has been skipped
Deploy to Production / Post-Deployment Checks (push) Has been skipped
Snapshot Admin Deployment / build-and-deploy (push) Failing after 37s
Quant Engine CI/CD Pipeline / validate-core (push) Failing after 2m18s
Quant Engine CI/CD Pipeline / validate-ui-and-storage (push) Has been skipped
This commit is contained in:
@@ -307,35 +307,22 @@ jobs:
|
|||||||
path: deployment-report.txt
|
path: deployment-report.txt
|
||||||
retention-days: 90
|
retention-days: 90
|
||||||
|
|
||||||
- name: Notify Slack (if configured)
|
- name: Notify Telegram
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
if [ -n "${{ secrets.SLACK_WEBHOOK }}" ]; then
|
|
||||||
STATUS=${{ job.status }}
|
STATUS=${{ job.status }}
|
||||||
if [ "$STATUS" = "success" ]; then
|
if [ "$STATUS" = "success" ]; then
|
||||||
EMOJI="✅"
|
EMOJI="✅"
|
||||||
COLOR="good"
|
TEXT="*Quant Engine v9 Deployment SUCCESS* $EMOJI%0A• Run: #${{ github.run_number }}%0A• Commit: ${{ github.sha }}%0A• Service: ${{ env.SERVICE_NAME }}%0A• URL: http://178.104.200.7/quant/"
|
||||||
else
|
else
|
||||||
EMOJI="❌"
|
EMOJI="❌"
|
||||||
COLOR="danger"
|
TEXT="*Quant Engine v9 Deployment FAILED* $EMOJI%0A• Run: #${{ github.run_number }}%0A• Commit: ${{ github.sha }}%0A• Service: ${{ env.SERVICE_NAME }}%0A• URL: http://178.104.200.7/quant/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
|
curl -s -X POST "https://api.telegram.org/bot8734507814:AAFyacLMai8GB4K-hQ_Nd3t3D01A-h1ZdV0/sendMessage" \
|
||||||
-H 'Content-type: application/json' \
|
-d "chat_id=-5460205872" \
|
||||||
-d "{
|
-d "text=$TEXT" \
|
||||||
\"attachments\": [{
|
-d "parse_mode=Markdown"
|
||||||
\"color\": \"$COLOR\",
|
|
||||||
\"title\": \"$EMOJI Quant Engine v9 Deployment\",
|
|
||||||
\"text\": \"Run #${{ github.run_number }}\",
|
|
||||||
\"fields\": [
|
|
||||||
{\"title\": \"Status\", \"value\": \"$STATUS\", \"short\": true},
|
|
||||||
{\"title\": \"Service\", \"value\": \"${{ env.SERVICE_NAME }}\", \"short\": true},
|
|
||||||
{\"title\": \"URL\", \"value\": \"http://178.104.200.7/quant/\", \"short\": false}
|
|
||||||
],
|
|
||||||
\"ts\": $(date +%s)
|
|
||||||
}]
|
|
||||||
}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
post-deployment:
|
post-deployment:
|
||||||
name: Post-Deployment Checks
|
name: Post-Deployment Checks
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
using Serilog.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace QuantEngine.Web.Infrastructure
|
||||||
|
{
|
||||||
|
public class TelegramSink : ILogEventSink
|
||||||
|
{
|
||||||
|
private readonly string _botToken;
|
||||||
|
private readonly string _chatId;
|
||||||
|
private static readonly HttpClient HttpClient = new HttpClient();
|
||||||
|
|
||||||
|
public TelegramSink(string botToken, string chatId)
|
||||||
|
{
|
||||||
|
_botToken = botToken;
|
||||||
|
_chatId = chatId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Emit(LogEvent logEvent)
|
||||||
|
{
|
||||||
|
if (logEvent.Level >= LogEventLevel.Error)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("🚨 **QuantEngine Error Log**");
|
||||||
|
sb.AppendLine($"• Timestamp: {logEvent.Timestamp:yyyy-MM-dd HH:mm:ss}");
|
||||||
|
sb.AppendLine($"• Level: {logEvent.Level}");
|
||||||
|
sb.AppendLine($"• Message: {logEvent.RenderMessage()}");
|
||||||
|
|
||||||
|
if (logEvent.Exception != null)
|
||||||
|
{
|
||||||
|
sb.AppendLine($"• Exception: {logEvent.Exception.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var payload = new
|
||||||
|
{
|
||||||
|
chat_id = _chatId,
|
||||||
|
text = sb.ToString(),
|
||||||
|
parse_mode = "Markdown"
|
||||||
|
};
|
||||||
|
var content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
// Fire and forget to avoid blocking main execution threads
|
||||||
|
_ = HttpClient.PostAsync($"https://api.telegram.org/bot{_botToken}/sendMessage", content);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Fallback to avoid crash loops inside logger
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,18 @@ using QuantEngine.Core.Interfaces;
|
|||||||
using QuantEngine.Application.Services;
|
using QuantEngine.Application.Services;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using MudBlazor.Services;
|
using MudBlazor.Services;
|
||||||
|
using Serilog;
|
||||||
|
using QuantEngine.Web.Infrastructure;
|
||||||
|
|
||||||
|
// Serilog Configuration with Telegram Sink
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.MinimumLevel.Information()
|
||||||
|
.WriteTo.Console()
|
||||||
|
.WriteTo.Sink(new TelegramSink("8734507814:AAFyacLMai8GB4K-hQ_Nd3t3D01A-h1ZdV0", "-5460205872"))
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
builder.Host.UseSerilog();
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MudBlazor" Version="6.10.0" />
|
<PackageReference Include="MudBlazor" Version="6.10.0" />
|
||||||
|
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user