name: Download Provisioning Profiles
inputs:
  app-store-key:
    description: App Store key in PEM PKCS#8 format
    required: true
  app-store-key-id:
    description: App Store key ID
    required: true
  app-store-key-issuer-id:
    description: App Store key issuer ID
    required: true
runs:
  using: composite
  steps:
  - shell: bash
    env:
      FASTLANE_OPT_OUT_USAGE: 'YES'
    run: |
      APP_STORE_KEY=$(echo "${{ inputs.app-store-key }}" | jq -sR .)
      cat << EOF > api-key.json
      {
        "key_id": "${{ inputs.app-store-key-id }}",
        "issuer_id": "${{ inputs.app-store-key-issuer-id }}",
        "key": $APP_STORE_KEY
      }
      EOF

      fastlane sigh download_all --api_key_path api-key.json

      rm -rf api-key.json
