name: "Setup environment"
description: "Performs common setup operations."
runs:
  using: "composite"
  steps:
    - name: Get go version
      id: golangversion
      run: |
        echo "go_version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
      shell: bash

    - name: Set up Go
      id: go
      uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
      with:
        go-version: ${{ steps.golangversion.outputs.go_version }}
        check-latest: true

    - name: Install kind
      run: sudo make install INSTALL_DIR=/usr/local/bin
      shell: bash

    - name: Install kubectl
      run: |
        curl -LO https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
        chmod +x ./kubectl
        sudo mv ./kubectl /usr/local/bin/kubectl
      shell: bash

    - name: Enable ipv4 and ipv6 forwarding
      run: |
        sudo sysctl -w net.ipv6.conf.all.forwarding=1
        sudo sysctl -w net.ipv4.ip_forward=1
      shell: bash
