name: Setup build env

description: Clone repo, unshallow, setup go, cache and install tools.

inputs:
  unshallow:
    description: git unshallow
    default: 'true'
  free-disk-space:
    description: free disk space
    default: 'true'

runs:
  using: composite
  steps:
    - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
      if: ${{ inputs.free-disk-space == 'true' }}
      with:
        android: true
        docker-images: false
        dotnet: true
        haskell: true
        large-packages: false
        swap-storage: false
        tool-cache: true
    - shell: bash
      if: ${{ inputs.unshallow == 'true' }}
      run: |
        git fetch --prune --unshallow
    - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
      with:
        go-version: ~1.23.1
    - shell: bash
      run: |
        go mod download
    - shell: bash
      run: |
        GOCACHE=~/.cache/kyverno/tools make install-tools