Repository: typesafegithub/github-workflows-kt (kotlin)

Issue:
[Core feature request] Add support for the merge_group trigger
**What feature do you need?**
GitHub recently released the new merge queue feature and a new related trigger for GitHub Actions: [`merge_group`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group).
This trigger is currently not supported in the Kotlin DSL.

**Do you have an example usage?**
```yaml
on:
  pull_request: 
  merge_group:
```

**Is there a workaround for not having this feature? If yes, please describe it.**
I have yet to find a workaround.

Pull request description:
closes #799

Patch:
diff --git a/library/api/library.api b/library/api/library.api
index e37d2ea5ff..b598ee220c 100644
--- a/library/api/library.api
+++ b/library/api/library.api
@@ -812,6 +812,37 @@ public final class io/github/typesafegithub/workflows/domain/triggers/Label$Comp
 	public final fun serializer ()Lkotlinx/serialization/KSerializer;
 }
 
+public final class io/github/typesafegithub/workflows/domain/triggers/MergeGroup : io/github/typesafegithub/workflows/domain/triggers/Trigger {
+	public static final field Companion Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup$Companion;
+	public fun <init> ()V
+	public synthetic fun <init> (ILjava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
+	public fun <init> (Ljava/util/Map;)V
+	public synthetic fun <init> (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+	public final fun component1 ()Ljava/util/Map;
+	public final fun copy (Ljava/util/Map;)Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup;
+	public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup;Ljava/util/Map;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup;
+	public fun equals (Ljava/lang/Object;)Z
+	public fun get_customArguments ()Ljava/util/Map;
+	public fun hashCode ()I
+	public fun toString ()Ljava/lang/String;
+	public static final synthetic fun write$Self (Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
+}
+
+public final class io/github/typesafegithub/workflows/domain/triggers/MergeGroup$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
+	public static final field INSTANCE Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup$$serializer;
+	public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
+	public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup;
+	public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
+	public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
+	public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/typesafegithub/workflows/domain/triggers/MergeGroup;)V
+	public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
+	public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
+}
+
+public final class io/github/typesafegithub/workflows/domain/triggers/MergeGroup$Companion {
+	public final fun serializer ()Lkotlinx/serialization/KSerializer;
+}
+
 public final class io/github/typesafegithub/workflows/domain/triggers/Milestone : io/github/typesafegithub/workflows/domain/triggers/Trigger {
 	public static final field Companion Lio/github/typesafegithub/workflows/domain/triggers/Milestone$Companion;
 	public fun <init> ()V
diff --git a/library/src/main/kotlin/io/github/typesafegithub/workflows/domain/triggers/MergeGroup.kt b/library/src/main/kotlin/io/github/typesafegithub/workflows/domain/triggers/MergeGroup.kt
new file mode 100644
index 0000000000..f1b52d324b
--- /dev/null
+++ b/library/src/main/kotlin/io/github/typesafegithub/workflows/domain/triggers/MergeGroup.kt
@@ -0,0 +1,12 @@
+package io.github.typesafegithub.workflows.domain.triggers
+
+import kotlinx.serialization.Contextual
+import kotlinx.serialization.Serializable
+
+/**
+ * https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group
+ */
+@Serializable
+public data class MergeGroup(
+    override val _customArguments: Map<String, @Contextual Any> = mapOf(),
+) : Trigger()
diff --git a/library/src/main/kotlin/io/github/typesafegithub/workflows/yaml/TriggersToYaml.kt b/library/src/main/kotlin/io/github/typesafegithub/workflows/yaml/TriggersToYaml.kt
index 3211cc7de8..db17fc3a83 100644
--- a/library/src/main/kotlin/io/github/typesafegithub/workflows/yaml/TriggersToYaml.kt
+++ b/library/src/main/kotlin/io/github/typesafegithub/workflows/yaml/TriggersToYaml.kt
@@ -16,6 +16,7 @@ import io.github.typesafegithub.workflows.domain.triggers.Gollum
 import io.github.typesafegithub.workflows.domain.triggers.IssueComment
 import io.github.typesafegithub.workflows.domain.triggers.Issues
 import io.github.typesafegithub.workflows.domain.triggers.Label
+import io.github.typesafegithub.workflows.domain.triggers.MergeGroup
 import io.github.typesafegithub.workflows.domain.triggers.Milestone
 import io.github.typesafegithub.workflows.domain.triggers.PageBuild
 import io.github.typesafegithub.workflows.domain.triggers.Project
@@ -109,6 +110,7 @@ public fun Trigger.triggerName(): String = when (this) {
     is IssueComment -> "issue_comment"
     is Issues -> "issues"
     is Label -> "label"
+    is MergeGroup -> "merge_group"
     is Milestone -> "milestone"
     is PageBuild -> "page_build"
     is Project -> "project"
diff --git a/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptgenerator/Triggers.kt b/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptgenerator/Triggers.kt
index fada17c76c..78749ba866 100644
--- a/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptgenerator/Triggers.kt
+++ b/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptgenerator/Triggers.kt
@@ -69,6 +69,7 @@ fun YamlWorkflowTriggers.toKotlin() = CodeBlock { builder ->
         .add(issue_comment.toKotlin("issue_comment"))
         .add(issues.toKotlin("issues"))
         .add(label.toKotlin("label"))
+        .add(merge_group.toKotlin("merge_group"))
         .add(milestone.toKotlin("milestone"))
         .add(page_build.toKotlin("page_build"))
         .add(public.toKotlin("public"))
diff --git a/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptmodel/YamlWorkflowTriggers.kt b/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptmodel/YamlWorkflowTriggers.kt
index ade87c225f..393cd9f0c9 100644
--- a/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptmodel/YamlWorkflowTriggers.kt
+++ b/script-generator/logic/src/main/kotlin/io/github/typesafegithub/workflows/scriptmodel/YamlWorkflowTriggers.kt
@@ -27,6 +27,7 @@ data class YamlWorkflowTriggers(
     val issue_comment: YamlTrigger? = null,
     val issues: YamlTrigger? = null,
     val label: YamlTrigger? = null,
+    val merge_group: YamlTrigger? = null,
     val milestone: YamlTrigger? = null,
     val page_build: YamlTrigger? = null,
     val project: YamlTrigger? = null,


Test patch:
diff --git a/library/src/test/kotlin/io/github/typesafegithub/workflows/domain/triggers/OtherTriggersTest.kt b/library/src/test/kotlin/io/github/typesafegithub/workflows/domain/triggers/OtherTriggersTest.kt
index debdb9bfe3..6dc8f5b457 100644
--- a/library/src/test/kotlin/io/github/typesafegithub/workflows/domain/triggers/OtherTriggersTest.kt
+++ b/library/src/test/kotlin/io/github/typesafegithub/workflows/domain/triggers/OtherTriggersTest.kt
@@ -22,6 +22,7 @@ class OtherTriggersTest : FunSpec({
             IssueComment(),
             Issues(),
             Label(),
+            MergeGroup(),
             Milestone(),
             PageBuild(),
             Project(),
@@ -59,6 +60,7 @@ class OtherTriggersTest : FunSpec({
             "issue_comment" to emptyMap<Any, Any>(),
             "issues" to emptyMap<Any, Any>(),
             "label" to emptyMap<Any, Any>(),
+            "merge_group" to emptyMap<Any, Any>(),
             "milestone" to emptyMap<Any, Any>(),
             "page_build" to emptyMap<Any, Any>(),
             "project" to emptyMap<Any, Any>(),
@@ -102,6 +104,7 @@ class OtherTriggersTest : FunSpec({
             IssueComment(types("created", "edited", "deleted")),
             Issues(types("opened", "edited")),
             Label(types("commented", "deleted", "edited")),
+            MergeGroup(),
             Milestone(types("created", "closed")),
             PageBuild(),
             Project(types("created", "deleted")),
@@ -139,6 +142,7 @@ class OtherTriggersTest : FunSpec({
             "issue_comment" to mapOf("types" to listOf("created", "edited", "deleted")),
             "issues" to mapOf("types" to listOf("opened", "edited")),
             "label" to mapOf("types" to listOf("commented", "deleted", "edited")),
+            "merge_group" to emptyMap<Any, Any>(),
             "milestone" to mapOf("types" to listOf("created", "closed")),
             "page_build" to emptyMap<Any, Any>(),
             "project" to mapOf("types" to listOf("created", "deleted")),