Skip to content

Commit

Permalink
Merge pull request #16 from gsmet/GetReleaseInformationAction
Browse files Browse the repository at this point in the history
Extract release information for both issue opened and issuecomment created
  • Loading branch information
gsmet authored Nov 25, 2023
2 parents 2fda63b + 05d2b1f commit 5362bf5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import jakarta.inject.Inject;

import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GHIssue;

import io.quarkiverse.githubaction.Action;
import io.quarkiverse.githubaction.Commands;
import io.quarkiverse.githubapp.event.Issue;
import io.quarkiverse.githubapp.event.IssueComment;
import io.quarkus.bot.release.util.Issues;
import io.quarkus.bot.release.util.Outputs;
Expand All @@ -16,15 +18,26 @@ public class GetReleaseInformationAction {
@Inject
Issues issues;

@Action("get-release-information")
void getReleaseInformation(Commands commands, @Issue.Opened GHEventPayload.Issue issuePayload) {
extractReleaseInformation(commands, issuePayload.getIssue());
}

@Action("get-release-information")
void getReleaseInformation(Commands commands, @IssueComment.Created GHEventPayload.IssueComment issueCommentPayload) {
extractReleaseInformation(commands, issueCommentPayload.getIssue());
}

private void extractReleaseInformation(Commands commands, GHIssue issue) {
commands.notice("Extracting release information...");

ReleaseInformation releaseInformation;

try {
UpdatedIssueBody updatedIssueBody = new UpdatedIssueBody(issueCommentPayload.getIssue().getBody());
UpdatedIssueBody updatedIssueBody = new UpdatedIssueBody(issue.getBody());
releaseInformation = issues.extractReleaseInformation(updatedIssueBody);
} catch (Exception e) {
releaseInformation = issues.extractReleaseInformationFromForm(issueCommentPayload.getIssue().getBody());
releaseInformation = issues.extractReleaseInformationFromForm(issue.getBody());
}

commands.setOutput(Outputs.BRANCH, releaseInformation.getBranch());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class GetReleaseStatusAction {

@Action("get-release-status")
void getReleaseStatus(Commands commands, @IssueComment.Created GHEventPayload.IssueComment issueCommentPayload) {
commands.notice("Extracting release status information...");

UpdatedIssueBody updatedIssueBody = new UpdatedIssueBody(issueCommentPayload.getIssue().getBody());

ReleaseStatus releaseStatus = issues.extractReleaseStatus(updatedIssueBody);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ void postInteractionComment(Commands commands, Inputs inputs,
}

private void postInteractionComment(Commands commands, Inputs inputs, GHIssue issue) throws IOException {
commands.notice("Posting interaction comment");

Optional<String> interactionCommentInput = inputs.get(Outputs.INTERACTION_COMMENT);
if (interactionCommentInput.isEmpty() || interactionCommentInput.get().isBlank()) {
commands.warning("No " + Outputs.INTERACTION_COMMENT + " input, not posting interaction comment");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/quarkus/bot/release/ReleaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class ReleaseAction {

@Action
void startRelease(Context context, Commands commands, @Issue.Opened GHEventPayload.Issue issuePayload) throws Exception {
commands.notice("Starting release...");

GHIssue issue = issuePayload.getIssue();
UpdatedIssueBody updatedIssueBody = new UpdatedIssueBody(issue.getBody());

Expand Down Expand Up @@ -88,6 +90,8 @@ void startRelease(Context context, Commands commands, @Issue.Opened GHEventPaylo
@Action
void onComment(Context context, Commands commands, @IssueComment.Created GHEventPayload.IssueComment issueCommentPayload)
throws Exception {
commands.notice("Continuing release...");

GHIssueComment issueComment = issueCommentPayload.getComment();
GHIssue issue = issueCommentPayload.getIssue();
UpdatedIssueBody updatedIssueBody = new UpdatedIssueBody(issue.getBody());
Expand Down

0 comments on commit 5362bf5

Please sign in to comment.