diff --git a/README.md b/README.md index b724785..f6d5277 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ -# action-template -github action template +# setup-java + +GitHub action to setup and configure java. +The aim is to abstract [public setup-java action](https://github.com/actions/setup-java) +to allow homemade customization, for example adding root ca certificate to the java truststore + +## Usage example + +```shell +name: Release + +on: + push: + branches: + - main + +jobs: + build: + if: "contains(github.event.head_commit.message, vars.SKIP_CI_PREFIX) != true" + + runs-on: runner + steps: + - uses: RouxAntoine/checkout@v3.5.4 + + - uses: antoine-roux.tk/projects/actions/setup-java@v1.0.0 + + - uses: RouxAntoine/auto-changie@v1.0.1 + + - name: Push changelog + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "${{ vars.SKIP_CI_PREFIX }} Push updated changelog" +``` diff --git a/action.yml b/action.yml index c3f75f2..2dc92c6 100644 --- a/action.yml +++ b/action.yml @@ -1,33 +1,39 @@ -name: 'Action-template' -description: 'Github action template' +name: 'setup-java' +description: | + Github action to setup java and adding custom root certificate in the truststore + see more information in official setup-java action + https://github.com/actions/setup-java branding: - icon: file - color: orange + icon: zap + color: gray-dark inputs: - sample-input: - description: 'input example' - default: 'default-value' + version: + description: 'java version to setup' + default: '21' + required: false + distribution: + description: 'java distribution to setup' + default: 'temurin' required: false runs: using: "composite" steps: - - name: Set GitHub Path example - run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH - shell: bash - env: - GITHUB_ACTION_PATH: ${{ github.action_path }} + - name: Retrieve root ca certificate + id: get-ca-cert + uses: RouxAntoine/get-ca-cert@v1.0.0 - - name: Set Github secret output result example - id: sets-a-secret - shell: bash - run: | - the_secret=$((RANDOM)) - echo "::add-mask::$the_secret" - echo "secret-number=$the_secret" >> "$GITHUB_OUTPUT" + - name: Setup java ${{ inputs.distribution }} version ${{ inputs.version }} + uses: actions/setup-java@v4 + id: java + with: + distribution: "${{ inputs.distribution }}" + java-version: "${{ inputs.version }}" + overwrite-settings: false - - name: Set Github output result example - id: sets-output - shell: bash - run: | - output_number=$((RANDOM)) - echo "output-number=$output_number" >> "$GITHUB_OUTPUT" \ No newline at end of file + - name: Add root certificate to java truststore + uses: RouxAntoine/add-ca-truststore@v1.1.0 + id: add-ca-to-truststore + with: + alias-name: antoine-roux.tk + ca-cert: "${{ steps.get-ca-cert.outputs.ca-cert }}" + store-path: "${{ steps.java.outputs.path }}/lib/security/cacerts"