name: "Setup Flutter SDK"
description: "Setup the Flutter SDK, and add it to the PATH"
branding:
  icon: "triangle"
  color: "blue"
inputs:
  version:
    description: "The version to install: Default: latest"
    required: false
    default: "latest"
  channel:
    description: 'The release channel to install. Default: stable'
    required: false
    default: 'stable'
  cache:
    description: 'Cache the pub dependencies. Default: false'
    required: false
    default: "false"
  cache-sdk:
    description: 'Cache the installed Flutter SDK. Default: false'
    required: false
    default: "false"
  cache-key:
    description: "An explicit key for restoring and saving the pub dependencies to/from cache"
    required: false
    default: "${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }}"
runs:
  using: "composite"
  steps:
    # Cache the Flutter SDK
    - if: ${{ inputs.cache-sdk == 'true' }}
      name: Configure Flutter SDK cache
      uses: actions/cache@v4
      with:
        path: ${{ runner.tool_cache }}/flutter-${{ runner.os }}-${{ inputs.version }}-${{ runner.arch }}
        key: flutter-action-setup-flutter-${{ runner.os }}-${{ inputs.version }}-${{ inputs.channel }}-${{ runner.arch }}
    # Cache the pub dependencies
    - if: ${{ inputs.cache == 'true' }}
      name: Configure pub dependencies cache
      uses: actions/cache@v4
      with:
        path: ${{ runner.temp }}/pub-cache
        key: flutter-action-setup-flutter-${{ runner.os }}-${{ inputs.version }}-${{ inputs.channel }}-${{ runner.arch }}-${{ inputs.cache-key }}-pub-cache
    # Run the action
    - name: Setup Flutter SDK
      run: $GITHUB_ACTION_PATH/action.sh ${{ inputs.version }} ${{ inputs.channel }}
      shell: bash
