Coder Social home page Coder Social logo

quarkiverse / quarkus-github-action Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 6.0 663 KB

Develop your GitHub Actions in Java with Quarkus.

Home Page: https://docs.quarkiverse.io/quarkus-github-action/dev/index.html

License: Apache License 2.0

Java 99.56% Kotlin 0.44%
quarkus-extension

quarkus-github-action's Introduction

Quarkus GitHub Action

Version

All Contributors

Develop your GitHub Actions in Java with Quarkus

Interested in GitHub Apps? Have a look at the Quarkus GitHub App extension.

Quarkus GitHub Action is a Quarkus extension that allows to create GitHub Actions in Java with very little boilerplate.

And yes, it supports generating native executables with GraalVM or Mandrel.

Your GitHub Action will look like:

class MyAction {

  @Action
  void doSomething() {
    // do something useful here
  }
}

Or you can also leverage the GitHub REST API (GraphQL is also supported), get the execution context, get the inputs, execute commands... with something a bit more involved:

class MyAction {

  @Action
  void onIssueOpened(@Issue.Opened GHEventPayload.Issue issuePayload, Context context, Inputs inputs, Commands commands) throws IOException {
    // Add a comment to the issue who triggered the job
    issuePayload.getIssue().comment("Hello from MyAction");

    // Set the value of an output
    commands.setOutput("output-key", "the value");

    // Append Markdown to the job summary
    commands.appendJobSummary(":wave: Hello from Quarkus GitHub Action");
  }
}

Quarkus GitHub Action will automatically inject all these fully initialized instances in the @Action methods for you.

Focus on your business logic and don't bother about the ceremony.

Compatibility

Quarkus GitHub Action 2.x is compatible with Quarkus 3.x.

We recommend using the latest versions of both for the best experience.

Documentation

To get you started (and more!), please refer to the extensive documentation.

Anything unclear or missing in the documentation? Please open an issue, we will address it quickly.

Examples

How?

The Quarkus GitHub Action extension uses the Hub4j GitHub API to parse the webhook payloads and handle the GitHub REST API calls.

It can also execute GraphQL queries towards the GitHub GraphQL API via the SmallRye GraphQL Client.

The rest of the extension is Quarkus magic - mostly code generation with Gizmo - to get everything wired.

Status

This extension is considered stable and is used in production.

It relies on the exact same principles as the Quarkus GitHub App extension.

License

This project is licensed under the Apache License Version 2.0.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Guillaume Smet
Guillaume Smet

💻 🚧
Jan-Petter Krüger
Jan-Petter Krüger

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

quarkus-github-action's People

Contributors

actions-user avatar allcontributors[bot] avatar dependabot[bot] avatar gastaldi avatar gsmet avatar ia3andy avatar janpk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

quarkus-github-action's Issues

Unable to resolve action <repo name>, repository not found, part 2

I have everything set up correctly.

2 repos
patricia-hartnett/gitHubActions_test1 - it will call the Java code in the other repo
patricia-hartnett/gitHubActions_testQuarkus5 - it has the Quarkiverse Java code in it.

patricia-hartnett/gitHubActions_testQuarkus5 looks like:
Screenshot 2023-01-19 at 11 40 36
Screenshot 2023-01-19 at 11 36 30
Screenshot 2023-01-19 at 11 35 53

In patricia-hartnett/gitHubActions_test1 I have an action whose workflow looks like:
Screenshot 2023-01-19 at 11 43 24

When this is run I get the repo not found error:
Screenshot 2023-01-19 at 12 00 20

I have tried pointing to both my own patricia-hartnett/gitHubActions_testQuarkus5 and gsmet/my-github-action. I get the same error message.
One of the things I noticed was that in the actions.yml file in patricia-hartnett/gitHubActions_testQuarkus5 , there is a line mentioning 'github=https://maven.pkg.github.com/patricia-hartnett/gitHubActions_testQuarkus5/....
Screenshot 2023-01-19 at 11 46 37
I tried going to this URL but I got a 404.
In fairness I also tried going to https://maven.pkg.github.com/gsmet/my-github-action/ (as mentioned here:https://github.com/gsmet/my-github-action/blob/9101a475431954e586525a565a3dd8ef75e48b7b/action.yml#L14) and still got a 404.

I have tried with and without a step doing actions/checkout@v3 in the action in patricia-hartnett/gitHubActions_test1 (where it attempts to call the Java code in the other repo), but I am still getting the same error message.
Both of my repos are set up as private but accessible from repositories owned by the user 'patricia-hartnett'.

Am I doing something wrong ?

mvn cmd in documentation does not run correctly

https://quarkiverse.github.io/quarkiverse-docs/quarkus-github-action/dev/create-github-action.html
mvn io.quarkus.platform:quarkus-maven-plugin:2.15.1.Final:create
-DprojectGroupId=org.acme \
-DprojectArtifactId=my-github-action \
-DprojectVersion=999-SNAPSHOT \
-DprojectName="My Action" \
-DprojectDescription="Description of my action" \
-Ddata=github-action-codestart.github-repository=my/action-github-repository \
-Dextensions="io.quarkiverse.githubaction:quarkus-github-action:1.0.1"

For me the -Ddata is patricia-hartnett/gitHibActions_testQuarkus, but apart from that I have not edited anything else in the mvn command.

When I run this the values are not being passed in.
mvn prompts me to fill in the values, but then it falls over with the error message:
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.15.1.Final:create (default-cli) on project artifactid: Failed to generate Quarkus project: Error while rendering template: /codestarts/quarkus/github-action-codestart/base/action.docker.tpl.qute.yml: Missing required data: {project.name} -> [Help 1]

Please see the screengrab attached.
I am using MacOS 12.6.1
I have 3.6.3 Maven

Screenshot 2023-01-17 at 14 54 53

Codestarter for Kotlin

I have been playing with this for a couple of days now(version 1.x), and have created a working action with Kotlin. It's not that bad of a process, but it would be nice with a codestarter for Kotlin in addition to the Java one. To be able use Kotlin you basically have to generate a Java version of the action and copy a number of files and update versions in the pom.xml

I tried to create a codestarter locally, but there is something I do not understand about the dependencies included in the pom.xml file. The Quarkus platform in the generated pom.xml is 2.5.1.Final. That is quite a tad old, and I suspect that the platform version is why the Kotlin version ends up being also quite outdated, with version 1.5.31.

I would be happy to create a pull request with the Kotlin codestarter, but with the outdated Platform/Kotlin version, it makes little sense doing it., since you still would have to manually update the Kotlin version in the pom.xml, along with the platform version. Also the java version of the action generated also ends up with platform version 2.5.1.Final.

Do you have any insights into how to address this? What I use to generate the action is

mvn io.quarkus.platform:quarkus-maven-plugin:2.16.4.Final:create -DprojectGroupId=org.acme -DprojectArtifactId=my-github-action4 -DprojectVersion=999-SNAPSHOT -DprojectName="My Action" -DprojectDescription="Description of my action" -Ddata="github-action-codestart.github-repository=my/action-github-repository" -Dextensions="kotlin,io.quarkiverse.githubaction:quarkus-github-action:1.0.1

Avoid using setup-java and rely on JBang installing Java

  • Using setup-java might cause problems as it can override the currently installed Java. Installing Java via JBang will avoid that.
  • Also, we should enforce the Java version (probably using --java 21) as Quarkus 3.7 will require Java 17 soon and that might break some workflows

Unable to resolve action <repo name>, repository not found

Hello, when I follow the Run your action instructions here
https://quarkiverse.github.io/quarkiverse-docs/quarkus-github-action/dev/create-github-action.html#_myaction_java

I am getting an error message:
Unable to resolve action patricia-hartnett/gitHibActions_testQuarkus2, repository not found

In my setup I have patricia-hartnett/gitHibActions_testQuarkus2:
Screenshot 2023-01-18 at 12 15 16
This is where the Java code and the docker image is.

And patricia-hartnett/gitHubActions_test1:
Screenshot 2023-01-18 at 12 12 09

This is how I define the workflow in this repo which is supposed to call the Quarkiverse code in patricia-hartnett/gitHibActions_testQuarkus2:
Screenshot 2023-01-18 at 12 21 45

I was wondering am I having the repository not found problem because patricia-hartnett/gitHibActions_testQuarkus2 is a private repo ?

Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.