Add Java as GitHub Action scripting language

Hi,

yesterday I created a POC Java program named Action.java handling the logic of an Action run.

Find the template repository here: https://github.com/sormuras/hello-world-java-action

It is based on the composite run steps action. An action.yml with runs: using: "composite" delegates via JEP 330 the thread of execution to a Java program.

Inputs of the Action are passed as command line arguments – but could also be set as system properties via -Dinputs.who-to-greet=${{ inputs.who-to-greet }}. The standard output stream (java.lang.System.out) is used to set output values of the Action.

What do you think? Is it useful? Perhaps a candidate to be added to the list of supported types of actions?

Caveats:

  • Requires that Java (JDK 11 or later) is pre-installed on every hosted runner and an environment variable with name JAVA_HOME_11_X64 points to its installation directory.
  • The current action.yml parser is used as the glue to invoke Action.java and it expects to find a ::set-output name=random-id::... for each input within the action.yml file.
2 Likes

I think it would be great to have java as a first class citizen in github actions.

JEP-330 is though quite limited which is why I create the project jbang.dev which also have its own action https://github.com/marketplace/actions/java-scripting-w-jbang

With this you can use Java 8 and higher, external dependencies , jshell, multiple files and more.

I would be curious to understand what if anything your JEP 330 action does that the jbang action does not and yes - lets make Java a first class option!

1 Like

@sormuras, @maxandersen,

Thanks for your feedback.
GitHub takes your suggestions very seriously, and the suggestions are very helpful for improving GitHub.

If you really want that adding Java as the scripts language of actions, I recommend that you can directly share your feature requests here. That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

1 Like

Done. :heavy_check_mark:

PS: Find another POC Action using the described technique at https://github.com/sormuras/download-jdk

1 Like

I thought Java was a compiled language, not a scripting language?

It’s compiled to byte code, which is then interpreted (translated to machine code) at runtime isn’t it?