Skip to content

Commit

Permalink
Extract release information for both issue opened and issuecomment cr…
Browse files Browse the repository at this point in the history
…eated
  • Loading branch information
gsmet committed Nov 25, 2023
1 parent 2fda63b commit 1491b2c
Showing 1 changed file with 15 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

0 comments on commit 1491b2c

Please sign in to comment.