fix(settings): build Forgejo release API from public URL (#316)
Heimdall Gitea / Detect CI scope (push) Successful in 5s
Heimdall Gitea / Build and tests (push) Successful in 19m44s
Heimdall Gitea / Build and scan server image (push) Successful in 10m40s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 14m9s
Heimdall Gitea / Build and scan agent image (push) Successful in 15m20s
Heimdall Gitea / Publish versioned installer release (push) Failing after 11m23s
Heimdall Gitea / CI policy (push) Failing after 3s

fix: derive Forgejo release API URL and bootstrap signed releases

Co-authored-by: Arnaud Dartois <admin@tordais.cc>
This commit was merged in pull request #316.
This commit is contained in:
arnaud.dartois authored and Arnaud Dartois committed 2026-11-10 10:11:50 +01:00
1 parent 24a2400610
commit 02783dd718
16 files changed
+243 -31

No files matched your search

+31 -4
View File
@@ -244,7 +244,7 @@ public partial class Program
await SeedGroupsAsync(groupDb);
var existingKeys = await GetExistingSettingKeysAsync(groupDb);
await SeedStorageSettingsAsync(groupDb, existingKeys);
await SeedIntegrationSettingsAsync(groupDb, existingKeys);
await SeedIntegrationSettingsAsync(groupDb, existingKeys, configuration);
await MigrateLegacySentryKeysAsync(groupDb);
await SeedDemoDataAsync(configuration, userManager, groupDb);
}
@@ -320,12 +320,39 @@ public partial class Program
await groupDb.SaveChangesWithRetryAsync();
}
private static async Task SeedIntegrationSettingsAsync(AppDbContext groupDb, HashSet<string> existingKeys)
private static async Task SeedIntegrationSettingsAsync(AppDbContext groupDb, HashSet<string> existingKeys,
IConfiguration configuration)
{
var heartbeatInterval = Environment.GetEnvironmentVariable("HEARTBEAT__INTERVAL_SECONDS");
if (!int.TryParse(heartbeatInterval, out var heartbeatSeconds) || heartbeatSeconds is < 5 or > 300)
heartbeatInterval = "30";
var configuredForgeUrl = configuration["Updates:ForgePublicUrl"];
var forgeUrlDefault = Heimdall.Web.Services.ForgeReleaseApiAddress.IsValidForgePublicUrl(configuredForgeUrl)
? configuredForgeUrl!.TrimEnd('/')
: Heimdall.Web.Services.ForgeReleaseApiAddress.DefaultForgePublicUrl;
var legacyReleaseSetting = await groupDb.AppSettings
.FirstOrDefaultAsync(setting => setting.Key == Heimdall.Web.Services.ForgeReleaseApiAddress.LegacySettingKey);
if (legacyReleaseSetting is not null)
{
var forgeSetting = await groupDb.AppSettings
.FirstOrDefaultAsync(setting => setting.Key == Heimdall.Web.Services.ForgeReleaseApiAddress.SettingKey);
if (forgeSetting is null)
{
groupDb.AppSettings.Add(new Heimdall.Domain.Entities.AppSetting(
Heimdall.Web.Services.ForgeReleaseApiAddress.SettingKey,
Heimdall.Web.Services.ForgeReleaseApiAddress.MigrateLegacyReleaseApiUrl(
legacyReleaseSetting.Value, forgeUrlDefault),
"updates",
"URL publique de Forgejo utilisée pour les releases Heimdall",
agentScoped: false));
existingKeys.Add(Heimdall.Web.Services.ForgeReleaseApiAddress.SettingKey);
}
groupDb.AppSettings.Remove(legacyReleaseSetting);
existingKeys.Remove(Heimdall.Web.Services.ForgeReleaseApiAddress.LegacySettingKey);
}
var defaults = new Dictionary<string, string?>
{
["ntfy.baseUrl"] = string.Empty,
@@ -339,7 +366,7 @@ public partial class Program
["email.useSsl"] = "true",
["ai.cpaiUrl"] = Environment.GetEnvironmentVariable("CPAI_URL"),
["ai.ollamaUrl"] = string.Empty,
["updates.releaseapiurl"] = string.Empty,
[Heimdall.Web.Services.ForgeReleaseApiAddress.SettingKey] = forgeUrlDefault,
["ai.detection.enabled"] = Environment.GetEnvironmentVariable("AI__DETECTION__ENABLED") ?? "true",
["log.level"] = Environment.GetEnvironmentVariable("LOG__LEVEL") ?? "info",
["log.retentionDays"] = Environment.GetEnvironmentVariable("LOG__RETENTION_DAYS") ?? "7",
@@ -378,7 +405,7 @@ public partial class Program
"email.useSsl" => "Utiliser SSL/TLS pour SMTP",
"ai.cpaiUrl" => "URL CodeProject.AI",
"ai.ollamaUrl" => "URL Ollama",
"updates.releaseapiurl" => "API des versions Heimdall (HTTPS)",
Heimdall.Web.Services.ForgeReleaseApiAddress.SettingKey => "URL publique Forgejo des releases Heimdall (HTTPS)",
"ai.detection.enabled" => "Détection IA activée par défaut",
"log.level" => "Niveau de log global (agents + central)",
"log.retentionDays" => "Rétention des logs agents (jours)",