name: Setup Conan
description: "Set up Conan configuration, profile, and remote."

inputs:
  conan_remote_name:
    description: "The name of the Conan remote to use."
    required: false
    default: xrplf
  conan_remote_url:
    description: "The URL of the Conan endpoint to use."
    required: false
    default: https://conan.ripplex.io

runs:
  using: composite

  steps:
    - name: Set up Conan configuration
      shell: bash
      run: |
        echo 'Installing configuration.'
        cat conan/global.conf ${{ runner.os == 'Linux' && '>>' || '>' }} $(conan config home)/global.conf

        echo 'Conan configuration:'
        conan config show '*'

    - name: Set up Conan profile
      shell: bash
      run: |
        echo 'Installing profile.'
        conan config install conan/profiles/default -tf $(conan config home)/profiles/

        echo 'Conan profile:'
        conan profile show

    - name: Set up Conan remote
      shell: bash
      env:
        CONAN_REMOTE_NAME: ${{ inputs.conan_remote_name }}
        CONAN_REMOTE_URL: ${{ inputs.conan_remote_url }}
      run: |
        echo "Adding Conan remote '${CONAN_REMOTE_NAME}' at '${CONAN_REMOTE_URL}'."
        conan remote add --index 0 --force "${CONAN_REMOTE_NAME}" "${CONAN_REMOTE_URL}"

        echo 'Listing Conan remotes.'
        conan remote list
