name: dotnet-nugetforunity-restore
description: "Restore NugetForUnity packages."
inputs:
  projectPath: 
    description: "Path to the Unity project."
    required: true
    default: "."
  restoreMode:
    description: "Whether or not to resture NuGetForUnity packages. Options: true, false, auto"
    required: true
    default: auto
runs:
  using: "composite"
  steps:
  - name: "Determine if NuGet packages need restored."
    id: nuget
    run: |
      NUGET="${{ inputs.restoreMode }}"
      if [ "$NUGET" == "auto" ]; then
        if [ -f "${{ inputs.projectPath }}/Assets/NuGet.config" ]; then
          NUGET=true
        else
          NUGET=false
        fi
      fi
      echo "restoreMode=$NUGET" >> "$GITHUB_OUTPUT"
    shell: bash
  - name: "Restore NuGet packages."
    if: ${{ steps.nuget.outputs.restoreMode == 'true' }}
    uses: act/common/dotnet/dotnet@master
    with:
      program: nugetforunity
      command: restore "${{ inputs.projectPath }}"
  - name: "Own artifacts."
    if: ${{ steps.nuget.outputs.restoreMode == 'true' }}
    uses: act/common/utils/chown@master
    with:
      file: ${{ inputs.projectPath }}/Assets/Packages
