feature: create action to setup-java and add root ca

This commit is contained in:
RouxAntoine 2024-09-07 14:00:40 +02:00
parent d22e935823
commit 87b59927a5
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
2 changed files with 64 additions and 27 deletions

View File

@ -1,2 +1,33 @@
# action-template # setup-java
github action template
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"
```

View File

@ -1,33 +1,39 @@
name: 'Action-template' name: 'setup-java'
description: 'Github action template' 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: branding:
icon: file icon: zap
color: orange color: gray-dark
inputs: inputs:
sample-input: version:
description: 'input example' description: 'java version to setup'
default: 'default-value' default: '21'
required: false
distribution:
description: 'java distribution to setup'
default: 'temurin'
required: false required: false
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Set GitHub Path example - name: Retrieve root ca certificate
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH id: get-ca-cert
shell: bash uses: RouxAntoine/get-ca-cert@v1.0.0
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- name: Set Github secret output result example - name: Setup java ${{ inputs.distribution }} version ${{ inputs.version }}
id: sets-a-secret uses: actions/setup-java@v4
shell: bash id: java
run: | with:
the_secret=$((RANDOM)) distribution: "${{ inputs.distribution }}"
echo "::add-mask::$the_secret" java-version: "${{ inputs.version }}"
echo "secret-number=$the_secret" >> "$GITHUB_OUTPUT" overwrite-settings: false
- name: Set Github output result example - name: Add root certificate to java truststore
id: sets-output uses: RouxAntoine/add-ca-truststore@v1.1.0
shell: bash id: add-ca-to-truststore
run: | with:
output_number=$((RANDOM)) alias-name: antoine-roux.tk
echo "output-number=$output_number" >> "$GITHUB_OUTPUT" ca-cert: "${{ steps.get-ca-cert.outputs.ca-cert }}"
store-path: "${{ steps.java.outputs.path }}/lib/security/cacerts"