/maven-cli-jdks-action

Github Action for Maven CLI using JDKs 8, 11, 13, 14, 15, 16 and 17 🤖 ☕️

Primary LanguageShellApache License 2.0Apache-2.0

Maven CLI JDKs Action

maven-cli-jdks-action

Github Action wrapping Maven CLI to run any Maven commands using JDK 8, 11, 13, 14, 15, 16 or 17 based on Maven DockerHub.

Those commands can be executed on the current repository directory, or in a specific one using a $DIRECTORY_PATH environment variable.

Workflow Demo

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    # Checkout your repository under $GITHUB_WORKSPACE, so your job can access your directories and files
    - uses: actions/checkout@v2

    # Runs a set of commands using the runners shell
    - name: Run maven commands
      uses: GuillaumeFalourd/maven-cli-jdks-action@main # Default is JDK 11
      env:
        DIRECTORY_PATH: java # Not mandatory (run on the repo root directory if not informed)
      with:
        commands: 'clean package test'

How does it work?

This workflow use a Dockerfile with Maven and a specific JDK installed to execute a Shell script file entrypoint.sh to perfom the following commands:

if [[ -z $DIRECTORY_PATH ]]; 
then
    echo "DIRECTORY_PATH env isn't set. Running in current directory"
else
    echo "Moving to specified directory path"
    cd $DIRECTORY_PATH
fi

echo "Executing command: mvn $1"

sh -c "mvn $1"

How to use a different JDK ?

For OpenJDK 8

uses: GuillaumeFalourd/maven-cli-action@jdk8

For OpenJDK 11 (main)

uses: GuillaumeFalourd/maven-cli-jdks-action@main

For OpenJDK 13

uses: GuillaumeFalourd/maven-cli-jdks-action@jdk13

For OpenJDK 14

uses: GuillaumeFalourd/maven-cli-jdks-action@jdk14

For OpenJDK 15

uses: GuillaumeFalourd/maven-cli-jdks-action@jdk15

For OpenJDK 16

uses: GuillaumeFalourd/maven-cli-jdks-action@jdk16

For OpenJDK 17

uses: GuillaumeFalourd/maven-cli-jdks-action@jdk17

Licensed

This repository uses the Apache License 2.0