nzuguem / nzuguem-github-bot

LLM-based Github App using Quarkus Github App and Quarkus Langchain4j extensions
MIT License
5 stars 0 forks source link

How to Initialize the configuration of GitHub App in Quarkus ? #20

Open nzuguem opened 9 months ago

nzuguem-github-app-dev[bot] commented 9 months ago

To initialize the configuration of a GitHub App in Quarkus, you need to follow these steps:

  1. Create a GitHub App: Register your GitHub App on the GitHub platform to obtain the necessary credentials such as the App ID, private key, and webhook secret. Follow the instructions provided in the GitHub documentation to register your app.

  2. Initialize your Quarkus application: Use the Quarkus CLI to create a new Quarkus application with the GitHub App extension. Run the following command in your terminal:

quarkus create app \
    -x quarkus-github-app \
    org.acme:my-github-app \
    --no-code

Replace org.acme:my-github-app with your desired group and artifact ID.

  1. Add the GitHub App extension dependency: Open the pom.xml file of your Quarkus application and add the quarkus-github-app dependency:
<dependency>
    <groupId>io.quarkiverse.githubapp</groupId>
    <artifactId>quarkus-github-app</artifactId>
    <version>{quarkus-github-app-version}</version>
</dependency>

Make sure to replace {quarkus-github-app-version} with the actual version of the Quarkus GitHub App extension.

  1. Configure the application: Create a .env file in the root directory of your Quarkus application and add the following environment variables with your GitHub App's credentials:
QUARKUS_GITHUB_APP_APP_ID=<the numeric app id>
QUARKUS_GITHUB_APP_APP_NAME=<the name of your app>
QUARKUS_GITHUB_APP_WEBHOOK_PROXY_URL=<your Smee.io channel URL>
QUARKUS_GITHUB_APP_WEBHOOK_SECRET=<your webhook secret>
QUARKUS_GITHUB_APP_PRIVATE_KEY=<your private key>

Replace the placeholders with the actual values you obtained when creating your GitHub App.

  1. Implement your GitHub App logic: Create Java classes that will handle the GitHub events. For example, to create a class that listens to issues and comments on them, you might have something like this:
import io.quarkiverse.githubapp.event.Issue;
import org.kohsuke.github.GHEventPayload;

class IssueCommenter {
    void onIssueOpened(@Issue.Opened GHEventPayload.Issue issuePayload) {
        // Logic to comment on the issue
    }
}
  1. Error handling: Optionally, you can implement a custom error handler by creating a CDI bean that implements io.quarkiverse.githubapp.error.ErrorHandler.

  2. Build and run your application: Use the Quarkus CLI or Maven to build and run your application. For a native executable, use:

quarkus build --native
  1. Deploy your GitHub App: Once your application is ready and tested, deploy it to a server or a cloud provider. Update your GitHub App's settings to point the webhook URL to your deployed application.

Remember to follow the Quarkus documentation and the GitHub App development guidelines for more detailed instructions and best practices.

Source : https://docs.quarkiverse.io/quarkus-github-app/dev/