-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from gsmet/improvements
Improvements
- Loading branch information
Showing
14 changed files
with
147 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/io/quarkus/bot/release/GetWorkflowRunIdAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.quarkus.bot.release; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.kohsuke.github.GHEventPayload; | ||
|
||
import io.quarkiverse.githubaction.Action; | ||
import io.quarkiverse.githubaction.Commands; | ||
import io.quarkiverse.githubapp.event.IssueComment; | ||
import io.quarkus.bot.release.util.Issues; | ||
import io.quarkus.bot.release.util.Outputs; | ||
|
||
public class GetWorkflowRunIdAction { | ||
|
||
@Inject | ||
Issues issues; | ||
|
||
@Action("get-workflow-run-id") | ||
void getWorkflowRunId(Commands commands, @IssueComment.Created GHEventPayload.IssueComment issueCommentPayload) { | ||
commands.setOutput(Outputs.WORKFLOW_RUN_ID, | ||
issues.extractReleaseStatus(issueCommentPayload.getIssue().getBody()).getWorkflowRunId().toString()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/io/quarkus/bot/release/PostInteractionCommentAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkus.bot.release; | ||
|
||
import java.io.IOException; | ||
import java.util.Optional; | ||
|
||
import org.kohsuke.github.GHEventPayload; | ||
import org.kohsuke.github.GHIssue; | ||
|
||
import io.quarkiverse.githubaction.Action; | ||
import io.quarkiverse.githubaction.Inputs; | ||
import io.quarkiverse.githubapp.event.Issue; | ||
import io.quarkiverse.githubapp.event.IssueComment; | ||
import io.quarkus.bot.release.util.Outputs; | ||
|
||
public class PostInteractionCommentAction { | ||
|
||
@Action("post-interaction-comment") | ||
void postInteractionComment(Inputs inputs, @Issue.Opened GHEventPayload.Issue issuePayload) throws IOException { | ||
postInteractionComment(inputs, issuePayload.getIssue()); | ||
} | ||
|
||
@Action("post-interaction-comment") | ||
void postInteractionComment(Inputs inputs, @IssueComment.Created GHEventPayload.IssueComment issueCommentPayload) | ||
throws IOException { | ||
postInteractionComment(inputs, issueCommentPayload.getIssue()); | ||
} | ||
|
||
private void postInteractionComment(Inputs inputs, GHIssue issue) throws IOException { | ||
Optional<String> interactionCommentInput = inputs.get(Outputs.INTERACTION_COMMENT); | ||
if (interactionCommentInput.isEmpty() || interactionCommentInput.get().isBlank()) { | ||
return; | ||
} | ||
|
||
issue.comment(interactionCommentInput.get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkus.bot.release.util; | ||
|
||
public final class Outputs { | ||
|
||
public static final String WORKFLOW_RUN_ID = "workflow-run-id"; | ||
public static final String INTERACTION_COMMENT = "interaction-comment"; | ||
|
||
private Outputs() { | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.bot.release.util; | ||
|
||
import java.util.Locale; | ||
|
||
public final class Users { | ||
|
||
public static final String QUARKUS_BOT = "quarkusbot"; | ||
public static final String BOT_SUFFIX = "[bot]"; | ||
public static final String BOT_SUFFIX_2 = "-bot"; | ||
|
||
private Users() { | ||
} | ||
|
||
public static boolean isBot(String login) { | ||
if (login == null || login.isBlank()) { | ||
return true; | ||
} | ||
|
||
String normalizedLogin = login.toLowerCase(Locale.ENGLISH).trim(); | ||
return normalizedLogin.equals(QUARKUS_BOT) | ||
|| normalizedLogin.endsWith(BOT_SUFFIX) | ||
|| normalizedLogin.endsWith(BOT_SUFFIX_2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.quarkus.bot.release; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.bot.release.util.Users; | ||
|
||
public class UsersTest { | ||
|
||
@Test | ||
void testIsBot() { | ||
assertThat(Users.isBot("gsmet")).isFalse(); | ||
assertThat(Users.isBot(null)).isTrue(); | ||
assertThat(Users.isBot("quarkusbot")).isTrue(); | ||
assertThat(Users.isBot("quarkus-bot")).isTrue(); | ||
assertThat(Users.isBot("github actions [bot]")).isTrue(); | ||
} | ||
} |