Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
49 changes: 33 additions & 16 deletions src/deploy-cromwell-on-azure/Deployer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,30 +1223,47 @@ private async Task BuildPushAcrAsync(Dictionary<string, string> settings, string
var build = await Execute($"Building TES and TriggerService images on {acr.Id.Name}...",
() => buildPushAcrRetryPolicy.ExecuteAsync(async () =>
{
AcrBuild build;
AcrBuild build = default;
{
IAsyncDisposable tarDisposable = default;
var loadSuccess = false;

try
for (var i = 2; i > 0 && !loadSuccess; --i, await Task.Delay(TimeSpan.FromSeconds(1), cts.Token))
{
IArchive tar;
IAsyncDisposable tarDisposable = default;

if (string.IsNullOrWhiteSpace(configuration.SolutionDir))
try
{
tar = AcrBuild.GetGitHubArchive(BuildType.CoA, string.IsNullOrWhiteSpace(configuration.GitHubCommit) ? new Version(targetVersion).ToString(3) : configuration.GitHubCommit, GitHubArchive.GetAccessTokenProvider());
tarDisposable = tar as IAsyncDisposable;
IArchive tar;

if (string.IsNullOrWhiteSpace(configuration.SolutionDir))
{
tar = AcrBuild.GetGitHubArchive(BuildType.CoA, string.IsNullOrWhiteSpace(configuration.GitHubCommit) ? new Version(targetVersion).ToString(3) : configuration.GitHubCommit, GitHubArchive.GetAccessTokenProvider());
tarDisposable = tar as IAsyncDisposable;
}
else
{
tar = AcrBuild.GetLocalGitArchiveAsync(new(configuration.SolutionDir));
}

build = new(BuildType.CoA, await tar.GetTagAsync(cts.Token), acr.Id, tokenCredential, new Azure.Containers.ContainerRegistry.ContainerRegistryAudience(azureCloudConfig.ArmEnvironment.Value.Endpoint.AbsoluteUri));
await build.LoadAsync(tar, azureCloudConfig.ArmEnvironment.Value, cts.Token);
}
else
catch (Microsoft.Kiota.Abstractions.ApiException ae) when ((int)HttpStatusCode.Unauthorized == ae.ResponseStatusCode)
{
tar = AcrBuild.GetLocalGitArchiveAsync(new(configuration.SolutionDir));
if (string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GITHUB_TOKEN")))
{
throw new InvalidOperationException("GitHub returned an authentication error.", ae);
}
else
{
Console.WriteLine("GitHub returned an authentication error. Retrying anonymously.");
Environment.SetEnvironmentVariable("GITHUB_TOKEN", null);
}
}
finally
{
await (tarDisposable?.DisposeAsync() ?? ValueTask.CompletedTask);
}

build = new(BuildType.CoA, await tar.GetTagAsync(cts.Token), acr.Id, tokenCredential, new Azure.Containers.ContainerRegistry.ContainerRegistryAudience(azureCloudConfig.ArmEnvironment.Value.Endpoint.AbsoluteUri));
await build.LoadAsync(tar, azureCloudConfig.ArmEnvironment.Value, cts.Token);
}
finally
{
await (tarDisposable?.DisposeAsync() ?? ValueTask.CompletedTask);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ga4gh-tes