Skip to content

Commit

Permalink
Improve GetReleaseInformationAction a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Nov 25, 2023
1 parent 05d2b1f commit 8cf7ff6
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import jakarta.inject.Inject;

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

import io.quarkiverse.githubaction.Action;
import io.quarkiverse.githubaction.Commands;
Expand All @@ -20,26 +19,23 @@ public class GetReleaseInformationAction {

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

ReleaseInformation releaseInformation = issues.extractReleaseInformationFromForm(issuePayload.getIssue().getBody());
outputReleaseInformation(commands, releaseInformation);
}

@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;
UpdatedIssueBody updatedIssueBody = new UpdatedIssueBody(issueCommentPayload.getIssue().getBody());
ReleaseInformation releaseInformation = issues.extractReleaseInformation(updatedIssueBody);

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

private void outputReleaseInformation(Commands commands, ReleaseInformation releaseInformation) {
commands.setOutput(Outputs.BRANCH, releaseInformation.getBranch());
if (releaseInformation.getQualifier() != null) {
commands.setOutput(Outputs.QUALIFIER, releaseInformation.getQualifier());
Expand Down

0 comments on commit 8cf7ff6

Please sign in to comment.