name: Setup environment
inputs:
  enable_go:
    type: boolean
    description: Whether to enable go specific features, such as caching.
    default: true
  enable_npm:
    type: boolean
    description: Whether to enable npm specific features, such as caching.
    default: false
  enable_docker_multibuild:
    type: boolean
    description: Whether to enable multibuild docker
    default: false
runs:
  using: composite
  steps:
    - uses: actions/cache@v3
      if: inputs.enable_go == 'true'
      with:
        path: |
          ~/.cache/go-build
          ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
    - uses: actions/cache@v3
      if: inputs.enable_npm == 'true'
      with:
        path: |
          ~/.npm
        key: ${{ runner.os }}-npm-${{ hashFiles('web/ui/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-npm-
    - run: make promu
      shell: bash
      if: inputs.enable_go == 'true'
    - name: Set up QEMU
      uses: docker/setup-qemu-action@v1
      if: inputs.enable_docker_multibuild == 'true'
    - name: Set up buildx
      uses: docker/setup-buildx-action@v1
      if: inputs.enable_docker_multibuild == 'true'
