Skip to content
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

Add GitHub action triggers for Label, Issue and IssuesComments #1424

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions build/Build.Announce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ partial class Build
}

IEnumerable<(string Text, string Url)> AnnouncementSponsors =>
new (string Text, string Url)[]
{
("Octopus Deploy", "https://octopus.com/"),
("Amazon Web Services", "https://aws.amazon.com/"),
};
[
("Octopus Deploy", "https://octopus.com/")
];

// https://api.slack.com/apps/A050ZLH0V40/incoming-webhooks?
[Parameter] [Secret] readonly string SlackWebhook;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System.Linq;
using JetBrains.Annotations;
using Nuke.Common.Tooling;
using Nuke.Common.Utilities;

namespace Nuke.Common.CI.GitHubActions.Configuration;

[PublicAPI]
public class GitHubActionsIssueCommentTrigger : GitHubActionsDetailedTrigger
{
public GitHubActionsIssueCommentType[] Types { get; set; }

public override void Write(CustomFileWriter writer)
{
writer.WriteLine("issue_comment:");
using (writer.Indent())
{
if (Types.Length > 0)
writer.WriteLine($"types: [{Types.Select(x => x.GetValue()).JoinCommaSpace()}]");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using Nuke.Common.Tooling;

namespace Nuke.Common.CI.GitHubActions.Configuration;

public enum GitHubActionsIssueCommentType
{
[EnumValue("created")] Created,
[EnumValue("edited")] Edited,
[EnumValue("deleted")] Deleted
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System.Linq;
using JetBrains.Annotations;
using Nuke.Common.Tooling;
using Nuke.Common.Utilities;

namespace Nuke.Common.CI.GitHubActions.Configuration;

[PublicAPI]
public class GitHubActionsIssueTrigger : GitHubActionsDetailedTrigger
{
public GitHubActionsIssueType[] Types { get; set; }

public override void Write(CustomFileWriter writer)
{
writer.WriteLine("issues:");
using (writer.Indent())
{
if (Types.Length > 0)
writer.WriteLine($"types: [{Types.Select(x => x.GetValue()).JoinCommaSpace()}]");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using Nuke.Common.Tooling;

namespace Nuke.Common.CI.GitHubActions.Configuration;

public enum GitHubActionsIssueType
{
[EnumValue("opened")]
Opened,

[EnumValue("edited")]
Edited,

[EnumValue("deleted")]
Deleted,

[EnumValue("transferred")]
Transferred,

[EnumValue("pinned")]
Pinned,

[EnumValue("unpinned")]
Unpinned,

[EnumValue("closed")]
Closed,

[EnumValue("reopened")]
Reopened,

[EnumValue("assigned")]
Assigned,

[EnumValue("unassigned")]
Unassigned,

[EnumValue("labeled")]
Labeled,

[EnumValue("unlabeled")]
Unlabeled,

[EnumValue("locked")]
Locked,

[EnumValue("unlocked")]
Unlocked,

[EnumValue("milestoned")]
Milestoned,

[EnumValue("demilestoned")]
Demilestoned
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System.Linq;
using JetBrains.Annotations;
using Nuke.Common.Tooling;
using Nuke.Common.Utilities;

namespace Nuke.Common.CI.GitHubActions.Configuration;

[PublicAPI]
public class GitHubActionsLabelTrigger : GitHubActionsDetailedTrigger
{
public GitHubActionsLabelType[] Types { get; set; }

public override void Write(CustomFileWriter writer)
{
writer.WriteLine("label:");
using (writer.Indent())
{
if (Types.Length > 0)
writer.WriteLine($"types: [{Types.Select(x => x.GetValue()).JoinCommaSpace()}]");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using Nuke.Common.Tooling;

namespace Nuke.Common.CI.GitHubActions.Configuration;

public enum GitHubActionsLabelType
{
[EnumValue("created")] Created,
[EnumValue("edited")] Edited,
[EnumValue("deleted")] Deleted
}
14 changes: 13 additions & 1 deletion source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ public GitHubActionsAttribute(
public string[] OnPullRequestExcludePaths { get; set; } = new string[0];
public string[] OnWorkflowDispatchOptionalInputs { get; set; } = new string[0];
public string[] OnWorkflowDispatchRequiredInputs { get; set; } = new string[0];
public GitHubActionsIssueCommentType[] OnIssueCommentTypes {get; set;} = new GitHubActionsIssueCommentType[0];
public GitHubActionsIssueType[] OnIssueTypes {get; set;} = new GitHubActionsIssueType[0];
public GitHubActionsLabelType[] OnLabelTypes {get; set;} = new GitHubActionsLabelType[0];
public string OnCronSchedule { get; set; }

public string[] ImportSecrets { get; set; } = new string[0];
public bool EnableGitHubToken { get; set; }
public GitHubActionsPermissions[] WritePermissions { get; set; } = new GitHubActionsPermissions[0];
Expand Down Expand Up @@ -278,5 +281,14 @@ protected virtual IEnumerable<GitHubActionsDetailedTrigger> GetTriggers()

if (OnCronSchedule != null)
yield return new GitHubActionsScheduledTrigger { Cron = OnCronSchedule };

if (OnIssueCommentTypes.Length > 0)
yield return new GitHubActionsIssueCommentTrigger { Types = OnIssueCommentTypes };

if (OnIssueTypes.Length > 0)
yield return new GitHubActionsIssueTrigger { Types = OnIssueTypes };

if (OnLabelTypes.Length > 0)
yield return new GitHubActionsLabelTrigger { Types = OnLabelTypes };
}
}