diff --git a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs index 43776b80d..c8f5c3146 100644 --- a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs +++ b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using JetBrains.Annotations; using Nuke.Common.CI; using Nuke.Common.CI.AppVeyor; using Nuke.Common.CI.AzurePipelines; @@ -48,6 +49,7 @@ public static IEnumerable GetAttributes() return TestBuild.GetAttributes().Select(x => new object[] { x.TestName, x.Generator }); } + [UsedImplicitly(ImplicitUseTargetFlags.WithMembers)] [AppVeyorSecret("GitHubToken", "encrypted-yaml")] [TeamCityToken("GitHubToken", "74928d76-46e8-45cc-ad22-6438915ac070")] public class TestBuild : NukeBuild @@ -161,7 +163,9 @@ public class TestBuild : NukeBuild TimeoutMinutes = 30, ConcurrencyCancelInProgress = true, JobConcurrencyCancelInProgress = true, - JobConcurrencyGroup = "custom-job-group" + JobConcurrencyGroup = "custom-job-group", + EnvironmentName = "environment-name", + EnvironmentUrl = "environment-url" } ); diff --git a/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsJob.cs b/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsJob.cs index 61dc3e4e8..817b9ba29 100644 --- a/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsJob.cs +++ b/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsJob.cs @@ -18,6 +18,8 @@ public class GitHubActionsJob : ConfigurationEntity public GitHubActionsImage Image { get; set; } public int TimeoutMinutes { get; set; } public string ConcurrencyGroup { get; set; } + public string EnvironmentName { get; set; } + public string EnvironmentUrl { get; set; } public bool ConcurrencyCancelInProgress { get; set; } public GitHubActionsStep[] Steps { get; set; } @@ -56,6 +58,23 @@ public override void Write(CustomFileWriter writer) } } + if (!EnvironmentName.IsNullOrWhiteSpace()) + { + if (EnvironmentUrl.IsNullOrWhiteSpace()) + { + writer.WriteLine($"environment: {EnvironmentName}"); + } + else + { + writer.WriteLine("environment:"); + using (writer.Indent()) + { + writer.WriteLine($"name: {EnvironmentName}"); + writer.WriteLine($"url: {EnvironmentUrl}"); + } + } + } + writer.WriteLine("steps:"); using (writer.Indent()) { diff --git a/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs b/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs index 8aef0f6fd..2c1f1599e 100644 --- a/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs +++ b/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs @@ -76,6 +76,9 @@ public GitHubActionsAttribute( public string PublishCondition { get; set; } public int TimeoutMinutes { get; set; } + + public string EnvironmentName { get; set; } + public string EnvironmentUrl { get; set; } public string ConcurrencyGroup { get; set; } public bool ConcurrencyCancelInProgress { get; set; } @@ -147,6 +150,8 @@ protected virtual GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyCo return new GitHubActionsJob { Name = image.GetValue().Replace(".", "_"), + EnvironmentName = EnvironmentName, + EnvironmentUrl = EnvironmentUrl, Steps = GetSteps(image, relevantTargets).ToArray(), Image = image, TimeoutMinutes = TimeoutMinutes,