Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve GetReleaseInformationAction a bit #17

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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