From 546b1438e8bcf60c73a891be0c5a190fa05e40a8 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 30 Sep 2022 09:33:32 -0400 Subject: [PATCH] Deployment creation errors shouldn't fail the job --- .../Remote/GitHubRemoteDeploymentManager.cs | 75 ++++++++++--------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs index a64a197587..c0d15ed98b 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs @@ -91,43 +91,50 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote else { Logger.LogTrace("Creating deployment..."); - var deployment = await gitHubClient - .Repository - .Deployment - .Create( - remoteInformation.RemoteRepositoryOwner, - remoteInformation.RemoteRepositoryName, - new NewDeployment(compileJob.RevisionInformation.CommitSha) - { - AutoMerge = false, - Description = "TGS Game Deployment", - Environment = $"TGS: {Metadata.Name}", - ProductionEnvironment = true, - RequiredContexts = new Collection(), - }) - .WithToken(cancellationToken) - ; + Octokit.Deployment deployment; - compileJob.GitHubDeploymentId = deployment.Id; - Logger.LogDebug("Created deployment ID {deploymentId}", deployment.Id); + try + { + deployment = await gitHubClient + .Repository + .Deployment + .Create( + remoteInformation.RemoteRepositoryOwner, + remoteInformation.RemoteRepositoryName, + new NewDeployment(compileJob.RevisionInformation.CommitSha) + { + AutoMerge = false, + Description = "TGS Game Deployment", + Environment = $"TGS: {Metadata.Name}", + ProductionEnvironment = true, + RequiredContexts = new Collection(), + }) + .WithToken(cancellationToken); - await gitHubClient - .Repository - .Deployment - .Status - .Create( - remoteInformation.RemoteRepositoryOwner, - remoteInformation.RemoteRepositoryName, - deployment.Id, - new NewDeploymentStatus(DeploymentState.InProgress) - { - Description = "The project is being deployed", - AutoInactive = false, - }) - .WithToken(cancellationToken) - ; + Logger.LogDebug("Created deployment ID {deploymentId}", deployment.Id); - Logger.LogTrace("In-progress deployment status created"); + await gitHubClient + .Repository + .Deployment + .Status + .Create( + remoteInformation.RemoteRepositoryOwner, + remoteInformation.RemoteRepositoryName, + deployment.Id, + new NewDeploymentStatus(DeploymentState.InProgress) + { + Description = "The project is being deployed", + AutoInactive = false, + }) + .WithToken(cancellationToken); + + compileJob.GitHubDeploymentId = deployment.Id; + Logger.LogTrace("In-progress deployment status created"); + } + catch (ApiException ex) + { + Logger.LogError(ex, "Unable to create deployment!"); + } } try