JDLuke / TestPipeline

This is simply there to test the centralized pipeline repository
0 stars 0 forks source link

Get default java version and distribution from configuration file #1

Open JDLuke opened 1 month ago

JDLuke commented 1 month ago

Create a default configuration file with the java distribution specified, then use that in any action which calls for installation.

Copilot suggested this, which seems close to correct.

- uses: actions/checkout@v4
  with:
    repository: owner/repo # Replace with your dedicated pipeline project repository
    path: cicd-project
    fetch-depth: 1
    sparse-checkout: 'default_values.yml'
- name: Read configuration
  id: config
  run: |
    if [ -f config.yml ]; then
      java_version=$(cat config.yml | grep java_version | awk '{print $2}')
    fi
    if [ -z "$java_version" ]; then
      if [ -f cicd-project/default_values.yml ]; then
        java_version=$(cat cicd-project/default_values.yml | grep java_version | awk '{print $2}')
      else
        java_version='17' # Fallback default value
      fi
    fi
    echo "JAVA_VERSION=$java_version" >> $GITHUB_ENV
- name: Set up Java
  uses: actions/setup-java@v2
  with:
    distribution: 'temurin'
    java-version: ${{ env.JAVA_VERSION }}
JDLuke commented 1 month ago

java_version: java_distribution: build_tool: