From 58b0c7e8b74901887fa2f1fc76941ae381aef2a1 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 13 Dec 2024 17:40:02 +0100 Subject: [PATCH] Add support for pull_request_target (actions only!) --- .../ROOT/pages/developer-reference.adoc | 4 + .../githubapp/event/PullRequestTarget.java | 148 ++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 events/src/main/java/io/quarkiverse/githubapp/event/PullRequestTarget.java diff --git a/docs/modules/ROOT/pages/developer-reference.adoc b/docs/modules/ROOT/pages/developer-reference.adoc index b6f3b9d7..2284529c 100644 --- a/docs/modules/ROOT/pages/developer-reference.adoc +++ b/docs/modules/ROOT/pages/developer-reference.adoc @@ -151,6 +151,10 @@ Here are all the events currently supported, together with the type of the paylo |`@PullRequestReviewComment.Created`, `@PullRequestReviewComment.Deleted`, `@PullRequestReviewComment.Edited` |link:{github-api-javadoc-root-url}/GHEventPayload.PullRequestReviewComment.html[`GHEventPayload.PullRequestReviewComment`] +|link:https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target[`pull_request_target`] (only for actions) +|`@PullRequestTarget.Assigned`, `@PullRequestTarget.Closed`, `@PullRequestTarget.Edited`, `@PullRequestTarget.Labeled`, `@PullRequestTarget.Locked`, `@PullRequestTarget.Opened`, `@PullRequestTarget.ReadyForReview`, `@PullRequestTarget.Reopened`, `@PullRequestTarget.ReviewRequested`, `@PullRequestTarget.ReviewRequestRemoved`, `@PullRequestTarget.Synchronize`, `@PullRequestTarget.Unassigned`, `@PullRequestTarget.Unlabeled`, `@PullRequestTarget.Unlocked` +|link:{github-api-javadoc-root-url}/GHEventPayload.PullRequest.html[`GHEventPayload.PullRequest`] + |link:{webhook-documentation-url}#push[`push`] |`@Push` |link:{github-api-javadoc-root-url}/GHEventPayload.Push.html[`GHEventPayload.Push`] diff --git a/events/src/main/java/io/quarkiverse/githubapp/event/PullRequestTarget.java b/events/src/main/java/io/quarkiverse/githubapp/event/PullRequestTarget.java new file mode 100644 index 00000000..9da9065e --- /dev/null +++ b/events/src/main/java/io/quarkiverse/githubapp/event/PullRequestTarget.java @@ -0,0 +1,148 @@ +package io.quarkiverse.githubapp.event; + +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import jakarta.inject.Qualifier; + +import org.kohsuke.github.GHEventPayload; + +@Event(name = "pull_request_target", payload = GHEventPayload.PullRequest.class) +@Target({ PARAMETER, TYPE }) +@Retention(RUNTIME) +@Qualifier +public @interface PullRequestTarget { + + String value() default Actions.ALL; + + @PullRequestTarget(Assigned.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Assigned { + + String NAME = Actions.ASSIGNED; + } + + @PullRequestTarget(Closed.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Closed { + + String NAME = Actions.CLOSED; + } + + @PullRequestTarget(Edited.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Edited { + + String NAME = Actions.EDITED; + } + + @PullRequestTarget(Labeled.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Labeled { + + String NAME = Actions.LABELED; + } + + @PullRequestTarget(Locked.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Locked { + + String NAME = Actions.LOCKED; + } + + @PullRequestTarget(Opened.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Opened { + + String NAME = Actions.OPENED; + } + + @PullRequestTarget(ReadyForReview.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface ReadyForReview { + + String NAME = Actions.READY_FOR_REVIEW; + } + + @PullRequestTarget(Reopened.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Reopened { + + String NAME = Actions.REOPENED; + } + + @PullRequestTarget(ReviewRequested.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface ReviewRequested { + + String NAME = Actions.REVIEW_REQUESTED; + } + + @PullRequestTarget(ReviewRequestRemoved.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface ReviewRequestRemoved { + + String NAME = Actions.REVIEW_REQUEST_REMOVED; + } + + @PullRequestTarget(Synchronize.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Synchronize { + + String NAME = Actions.SYNCHRONIZE; + } + + @PullRequestTarget(Unassigned.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Unassigned { + + String NAME = Actions.UNASSIGNED; + } + + @PullRequestTarget(Unlabeled.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Unlabeled { + + String NAME = Actions.UNLABELED; + } + + @PullRequestTarget(Unlocked.NAME) + @Target(PARAMETER) + @Retention(RUNTIME) + @Qualifier + public @interface Unlocked { + + String NAME = Actions.UNLOCKED; + } + +}