Skip to content

ci: Dotty will now create issues in our repo for new package versions it finds #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .github/workflows/nuget_slack_notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
nuget-slack-notifications:
name: Check for core technology package updates
runs-on: ubuntu-latest
permissions:
issues: write
continue-on-error: false

env:
Expand Down Expand Up @@ -60,6 +62,7 @@ jobs:

env:
DOTTY_WEBHOOK: ${{ secrets.SLACK_NUGET_NOTIFICATIONS_WEBHOOK }}
DOTTY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CORECLR_ENABLE_PROFILING: 1
CORECLR_NEWRELIC_HOME: ${{ env.scan-tool-path }}/bin/Debug/net6.0/newrelic
CORECLR_PROFILER: "{36032161-FFC0-4B61-B559-F6C5D41BAE5A}"
Expand Down
28 changes: 27 additions & 1 deletion .github/workflows/scripts/nugetSlackNotifications/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NewRelic.Api.Agent;
using Octokit;
using Serilog;
using Serilog.Core;
using System;
using System.Collections.Generic;
using System.Net;
Expand All @@ -23,6 +23,7 @@ public class Program
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
private static readonly bool _testMode = bool.TryParse(Environment.GetEnvironmentVariable("DOTTY_TEST_MODE"), out var testMode) ? testMode : false;
private static readonly string? _webhook = Environment.GetEnvironmentVariable("DOTTY_WEBHOOK");
private static readonly string? _githubToken = Environment.GetEnvironmentVariable("DOTTY_TOKEN");


static async Task Main(string[] args)
Expand All @@ -43,6 +44,7 @@ static async Task Main(string[] args)
}

await AlertOnNewVersions();
await CreateGithubIssuesForNewVersions();

}

Expand Down Expand Up @@ -117,6 +119,30 @@ static async Task AlertOnNewVersions()
}
}

[Transaction]
static async Task CreateGithubIssuesForNewVersions()
{

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
{
var ghClient = new GitHubClient(new ProductHeaderValue("Dotty-Robot"));
var tokenAuth = new Credentials(_githubToken);
ghClient.Credentials = tokenAuth;
foreach (var versionData in _newVersions)
{
var newIssue = new NewIssue($"Dotty: update tests for {versionData.PackageName} from {versionData.OldVersion} to {versionData.NewVersion}");
newIssue.Body = versionData.Url;
newIssue.Labels.Add("testing");
newIssue.Labels.Add("Core Technologies");
var issue = await ghClient.Issue.Create("newrelic", "newrelic-dotnet-agent", newIssue);
}
}
else
{
Log.Information($"Issues will not be created: # of new versions={_newVersions.Count}, token available={_webhook != null}, test mode={_testMode}");
}
}

[Trace]
static async Task SendSlackNotification(string msg)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="NewRelic.Agent.Api" Version="10.3.0" />
<PackageReference Include="Octokit" Version="6.0.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>
Expand Down