diff --git a/.github/workflows/nuget_slack_notifications.yml b/.github/workflows/nuget_slack_notifications.yml index f130251ea6..40db48d3a2 100644 --- a/.github/workflows/nuget_slack_notifications.yml +++ b/.github/workflows/nuget_slack_notifications.yml @@ -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: @@ -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}" diff --git a/.github/workflows/scripts/nugetSlackNotifications/Program.cs b/.github/workflows/scripts/nugetSlackNotifications/Program.cs index ed9594c978..c236d6e6f9 100644 --- a/.github/workflows/scripts/nugetSlackNotifications/Program.cs +++ b/.github/workflows/scripts/nugetSlackNotifications/Program.cs @@ -1,6 +1,6 @@ using NewRelic.Api.Agent; +using Octokit; using Serilog; -using Serilog.Core; using System; using System.Collections.Generic; using System.Net; @@ -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) @@ -43,6 +44,7 @@ static async Task Main(string[] args) } await AlertOnNewVersions(); + await CreateGithubIssuesForNewVersions(); } @@ -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) { diff --git a/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj b/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj index 8e73d5e0ad..b4eaccd11f 100644 --- a/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj +++ b/.github/workflows/scripts/nugetSlackNotifications/nugetSlackNotifications.csproj @@ -9,6 +9,7 @@ +