Skip to content

Commit

Permalink
ci: Fix exception when creating GitHub issue in NugetVersionDeprecator (
Browse files Browse the repository at this point in the history
  • Loading branch information
nr-ahemsath authored Feb 28, 2024
1 parent 7c1c34d commit 61e200a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ updates:
directory: /src/NewRelic.Core
schedule:
interval: weekly
- package-ecosystem: nuget
directory: /build
schedule:
interval: weekly
8 changes: 4 additions & 4 deletions build/NugetVersionDeprecator/NugetVersionDeprecator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand All @@ -19,11 +19,11 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NuGet.Protocol" Version="6.6.1" />
<PackageReference Include="Octokit" Version="7.1.0" />
<PackageReference Include="NuGet.Protocol" Version="6.9.1" />
<PackageReference Include="Octokit" Version="10.0.0" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
<PackageReference Include="YamlDotNet" Version="13.1.1" />
<PackageReference Include="YamlDotNet" Version="15.1.2" />
</ItemGroup>

</Project>
27 changes: 22 additions & 5 deletions build/NugetVersionDeprecator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 New Relic, Inc. All rights reserved.
// Copyright 2023 New Relic, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

using System.Text;
Expand Down Expand Up @@ -54,7 +54,15 @@ static async Task<int> Main(string[] args)
Console.WriteLine(message);

if (!options.TestMode)
await CreateGhIssueAsync(message, options.GithubToken);
{
var success = await CreateGhIssueAsync(message, options.GithubToken);
if (!success)
{
Console.WriteLine("Error creating GitHub issue.");
return -1;
}
}

}
}
else
Expand Down Expand Up @@ -155,7 +163,7 @@ p.DeprecationMetadata is null // not deprecated
new PackageDeprecationInfo() { PackageName = p.PackageId, PackageVersion = p.Version.ToString() });
}

static async Task CreateGhIssueAsync(string message, string githubToken)
static async Task<bool> CreateGhIssueAsync(string message, string githubToken)
{
var ghClient = new GitHubClient(new Octokit.ProductHeaderValue("NugetVersionDeprecator"));
var tokenAuth = new Credentials(githubToken);
Expand All @@ -170,9 +178,18 @@ static async Task CreateGhIssueAsync(string message, string githubToken)
newIssue.Labels.Add("Deprecation");
newIssue.Labels.Add("Nuget");

var issue = await ghClient.Issue.Create("newrelic", "newrelic-dotnet-agent", newIssue);
try
{
var issue = await ghClient.Issue.Create("newrelic", "newrelic-dotnet-agent", newIssue);
Console.WriteLine($"Created new GitHub Issue #{issue.Number} with title {issue.Title}.");
return true;
}
catch (Exception ex)
{
Console.WriteLine($"Caught exception attepting to create GitHub issue: {ex.Message}.");
return false;
}

Console.WriteLine($"Created new GitHub Issue #{issue.Number} with title {issue.Title}.");
}

static Configuration LoadConfiguration(string path)
Expand Down

0 comments on commit 61e200a

Please sign in to comment.