name: "Setup vcpkg"
description: "Sets up vcpkg"
inputs:
  vcpkg-sha:
    description: "vcpkg git sha to use"
    required: true
  nuget-source:
    description: "The nuget json"
    required: true
  nuget-username:
    description: "The username for the nuget repository"
    required: true
  nuget-pat:
    description: "The PAT for the nuget repository"
    required: true
  mono:
    description: "mono exec"
    required: true


runs:
  using: "composite"
  steps:
    - name: checkout vcpkg
      uses: actions/checkout@v4
      with:
        repository: "microsoft/vcpkg"
        ref: ${{ inputs.vcpkg-sha }}
        path: vcpkg

    - name: "Setup vcpkg"
      shell: bash
      run: ./vcpkg/bootstrap-vcpkg.sh

    - name: "Setup NuGet Credentials"
      shell: "bash"
      run: >
        ${{ inputs.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
        sources add
        -source "${{ inputs.nuget-source }}"
        -storepasswordincleartext
        -name "GitHub"
        -username "${{ inputs.nuget-username }}"
        -password "${{ inputs.nuget-pat }}"

    - name: "Setup NuGet apikey"
      shell: "bash"
      run: >
        ${{ inputs.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
        setapikey "${{ inputs.nuget-pat }}" -Source "${{ inputs.nuget-source }}"
