on:
  workflow_call:
    inputs:
      overlay:
        required: true
        type: string
    secrets:
      KUBE_CONFIG:
        required: true


name: Deploy the newly built container


jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:

    - uses: https://gitea.com/actions/checkout@v4
      with:
        submodules: true

    - name: setup kubectl
      uses: https://github.com/azure/setup-kubectl@v4

    - name: Set kubeconfig
      run: |
        echo "${{ secrets.KUBE_CONFIG }}" > kubeconfig

    - name: Deploy to k8s
      run: |
        kubectl apply -k backend/deployment/overlays/${{ inputs.overlay }} --kubeconfig=kubeconfig
        kubectl -n anyway-backend rollout restart deployment/anyway-backend-${{ inputs.overlay }}
