name: Kyma Setup

description: "Installs dependencies for Kyma deployment"

inputs:
  registry:
    description: Image Registry
    required: true
  user:
    description: Registry User
    required: true
  password:
    description: Registry Password
    required: true
  kube-config:
    description: Base64-encoded Kubernetes Config
    required: true

runs:
  using: "composite"
  steps:
    - run: apt-get update -y
      shell: bash
    - run: apt-get install software-properties-common -y
      shell: bash
    - run: apt-get install curl ca-certificates -y
      shell: bash
    - run: apt install sudo
      shell: bash
    - run: curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
      shell: bash
    - run: echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
      shell: bash
    - run: apt-get update -y
      shell: bash
    - run: apt-get install make -y
      shell: bash
    - run: apt-get install maven -y
      shell: bash
    - run: apt-get install docker.io -y
      shell: bash
    - run: (curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-linux.tgz" | sudo tar -C /usr/local/bin/ --no-same-owner -xzv pack)
      shell: bash
    - run: apt-get install kubectl -y
      shell: bash
    - run: curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
      shell: bash
    - shell: bash
      run: |
          mkdir ${HOME}/kyma-binaries
          export PATH=${HOME}/kyma-binaries/:$PATH
          echo "${{ inputs.password }}" | docker login "${{ inputs.registry }}" -u "${{ inputs.user }}" --password-stdin
          mkdir ${HOME}/.kube
          echo "${{ inputs.kube-config }}" | base64 --decode > ${HOME}/.kube/config
