name: "Pull Git LFS Objects"
description: "Pull only LFS objects for changed skins and core assets"

inputs:
  changed_skins_file:
    description: "Path to file containing changed skins"
    required: false
    default: ""

runs:
  using: "composite"
  steps:
    - name: Pull Git LFS objects
      shell: bash
      run: |
        if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then
          echo "No skins changed. Skipping git pull lfs."
          exit 0
        fi

        includes="src/**,export/**,media/**"

        skin_includes=$(
          while IFS= read -r skin; do
            esc=$(printf '%s' "$skin" \
              | sed -e 's/\[/\\[/g' -e 's/\]/\\]/g')
            printf 'Skins/%s/**\n' "$esc"
          done < "${{ inputs.changed_skins_file }}" \
          | paste -sd ','
        )

        includes="$includes,$skin_includes"

        echo "→ Pulling LFS objects for patterns: $includes"
        git lfs pull --include="$includes"
