Skip to content

Commit 0e86e4b

Browse files
authored
ci: let the core tech update scanner create issues in our repo for the new package versions it finds (#1696)
1 parent a5ce546 commit 0e86e4b

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.github/workflows/nuget_slack_notifications.yml

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
nuget-slack-notifications:
2525
name: Check for core technology package updates
2626
runs-on: ubuntu-latest
27+
permissions:
28+
issues: write
2729
continue-on-error: false
2830

2931
env:
@@ -60,6 +62,7 @@ jobs:
6062

6163
env:
6264
DOTTY_WEBHOOK: ${{ secrets.SLACK_NUGET_NOTIFICATIONS_WEBHOOK }}
65+
DOTTY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6366
CORECLR_ENABLE_PROFILING: 1
6467
CORECLR_NEWRELIC_HOME: ${{ env.scan-tool-path }}/bin/Debug/net6.0/newrelic
6568
CORECLR_PROFILER: "{36032161-FFC0-4B61-B559-F6C5D41BAE5A}"

.github/workflows/scripts/nugetSlackNotifications/Program.cs

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using NewRelic.Api.Agent;
2+
using Octokit;
23
using Serilog;
3-
using Serilog.Core;
44
using System;
55
using System.Collections.Generic;
66
using System.Net;
@@ -23,6 +23,7 @@ public class Program
2323
private static readonly int _daysToSearch = int.TryParse(Environment.GetEnvironmentVariable("DOTTY_DAYS_TO_SEARCH"), out var days) ? days : 1; // How many days of package release history to scan for changes
2424
private static readonly bool _testMode = bool.TryParse(Environment.GetEnvironmentVariable("DOTTY_TEST_MODE"), out var testMode) ? testMode : false;
2525
private static readonly string? _webhook = Environment.GetEnvironmentVariable("DOTTY_WEBHOOK");
26+
private static readonly string? _githubToken = Environment.GetEnvironmentVariable("DOTTY_TOKEN");
2627

2728

2829
static async Task Main(string[] args)
@@ -43,6 +44,7 @@ static async Task Main(string[] args)
4344
}
4445

4546
await AlertOnNewVersions();
47+
await CreateGithubIssuesForNewVersions();
4648

4749
}
4850

@@ -117,6 +119,30 @@ static async Task AlertOnNewVersions()
117119
}
118120
}
119121

122+
[Transaction]
123+
static async Task CreateGithubIssuesForNewVersions()
124+
{
125+
126+
if (_newVersions.Count > 0 && _githubToken != null && !_testMode) // only message channel if there's package updates to report AND we have a GH token from the environment AND we're not in test mode
127+
{
128+
var ghClient = new GitHubClient(new ProductHeaderValue("Dotty-Robot"));
129+
var tokenAuth = new Credentials(_githubToken);
130+
ghClient.Credentials = tokenAuth;
131+
foreach (var versionData in _newVersions)
132+
{
133+
var newIssue = new NewIssue($"Dotty: update tests for {versionData.PackageName} from {versionData.OldVersion} to {versionData.NewVersion}");
134+
newIssue.Body = versionData.Url;
135+
newIssue.Labels.Add("testing");
136+
newIssue.Labels.Add("Core Technologies");
137+
var issue = await ghClient.Issue.Create("newrelic", "newrelic-dotnet-agent", newIssue);
138+
}
139+
}
140+
else
141+
{
142+
Log.Information($"Issues will not be created: # of new versions={_newVersions.Count}, token available={_webhook != null}, test mode={_testMode}");
143+
}
144+
}
145+
120146
[Trace]
121147
static async Task SendSlackNotification(string msg)
122148
{

.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="NewRelic.Agent.Api" Version="10.3.0" />
12+
<PackageReference Include="Octokit" Version="6.0.0" />
1213
<PackageReference Include="Serilog" Version="2.12.0" />
1314
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
1415
</ItemGroup>

0 commit comments

Comments
 (0)