Skip to content

Commit 61e200a

Browse files
authored
ci: Fix exception when creating GitHub issue in NugetVersionDeprecator (#2280)
1 parent 7c1c34d commit 61e200a

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

.github/dependabot.yml

+4
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ updates:
2020
directory: /src/NewRelic.Core
2121
schedule:
2222
interval: weekly
23+
- package-ecosystem: nuget
24+
directory: /build
25+
schedule:
26+
interval: weekly

build/NugetVersionDeprecator/NugetVersionDeprecator.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

@@ -19,11 +19,11 @@
1919
<ItemGroup>
2020
<PackageReference Include="CommandLineParser" Version="2.9.1" />
2121
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
22-
<PackageReference Include="NuGet.Protocol" Version="6.6.1" />
23-
<PackageReference Include="Octokit" Version="7.1.0" />
22+
<PackageReference Include="NuGet.Protocol" Version="6.9.1" />
23+
<PackageReference Include="Octokit" Version="10.0.0" />
2424
<PackageReference Include="RestSharp" Version="110.2.0" />
2525
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
26-
<PackageReference Include="YamlDotNet" Version="13.1.1" />
26+
<PackageReference Include="YamlDotNet" Version="15.1.2" />
2727
</ItemGroup>
2828

2929
</Project>

build/NugetVersionDeprecator/Program.cs

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 New Relic, Inc. All rights reserved.
1+
// Copyright 2023 New Relic, Inc. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

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

5656
if (!options.TestMode)
57-
await CreateGhIssueAsync(message, options.GithubToken);
57+
{
58+
var success = await CreateGhIssueAsync(message, options.GithubToken);
59+
if (!success)
60+
{
61+
Console.WriteLine("Error creating GitHub issue.");
62+
return -1;
63+
}
64+
}
65+
5866
}
5967
}
6068
else
@@ -155,7 +163,7 @@ p.DeprecationMetadata is null // not deprecated
155163
new PackageDeprecationInfo() { PackageName = p.PackageId, PackageVersion = p.Version.ToString() });
156164
}
157165

158-
static async Task CreateGhIssueAsync(string message, string githubToken)
166+
static async Task<bool> CreateGhIssueAsync(string message, string githubToken)
159167
{
160168
var ghClient = new GitHubClient(new Octokit.ProductHeaderValue("NugetVersionDeprecator"));
161169
var tokenAuth = new Credentials(githubToken);
@@ -170,9 +178,18 @@ static async Task CreateGhIssueAsync(string message, string githubToken)
170178
newIssue.Labels.Add("Deprecation");
171179
newIssue.Labels.Add("Nuget");
172180

173-
var issue = await ghClient.Issue.Create("newrelic", "newrelic-dotnet-agent", newIssue);
181+
try
182+
{
183+
var issue = await ghClient.Issue.Create("newrelic", "newrelic-dotnet-agent", newIssue);
184+
Console.WriteLine($"Created new GitHub Issue #{issue.Number} with title {issue.Title}.");
185+
return true;
186+
}
187+
catch (Exception ex)
188+
{
189+
Console.WriteLine($"Caught exception attepting to create GitHub issue: {ex.Message}.");
190+
return false;
191+
}
174192

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

178195
static Configuration LoadConfiguration(string path)

0 commit comments

Comments
 (0)